blob: 625f84d9f7b666b55610713718bde3e5fd6172bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
from odoo.exceptions import UserError
from odoo.tools.float_utils import float_round
from odoo import models, fields, api, _
import logging
_logger = logging.getLogger(__name__)
class ReturnPicking(models.TransientModel):
_inherit = 'stock.return.picking'
def create_returns(self):
if (
self.env.user.id not in [12, 10, 2, 15, 22]
and 'BU/IN' in self.picking_id.name
and 'PO/' in self.picking_id.origin
and self.picking_id.picking_type_code == 'incoming'
):
raise UserError(_("Anda tidak memiliki akses untuk melakukan Retur Barang"))
# super harus manggil class ini sendiri
res = super(ReturnPicking, self).create_returns()
return res
class ReturnPickingLine(models.TransientModel):
_inherit = 'stock.return.picking.line'
@api.onchange('quantity')
def _onchange_quantity(self):
for rec in self:
if rec.move_id and rec.quantity > 0:
qty_done = rec.move_id.quantity_done
if qty_done == 0:
qty_done = rec.move_id.product_uom_qty
if rec.quantity > qty_done:
raise UserError(
_("Quantity yang Anda masukkan (%.2f) tidak boleh melebihi quantity done yaitu: %.2f untuk produk %s")
% (rec.quantity, qty_done, rec.product_id.name)
)
|