summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/stock_picking_return.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/indoteknik_custom/models/stock_picking_return.py b/indoteknik_custom/models/stock_picking_return.py
index a4a3a500..91a3a9fd 100644
--- a/indoteknik_custom/models/stock_picking_return.py
+++ b/indoteknik_custom/models/stock_picking_return.py
@@ -13,7 +13,15 @@ class ReturnPicking(models.TransientModel):
stock_picking = self.env['stock.picking'].search([
('id', '=', res['picking_id']),
])
- if not stock_picking.approval_return_status == 'approved':
- raise UserError('Harus Approval Accounting untuk melakukan Retur')
+
+ sale_id = stock_picking.group_id.sale_id
+ if not stock_picking.approval_return_status == 'approved' and sale_id.invoice_ids:
+ raise UserError('Harus Approval Accounting AR untuk melakukan Retur')
+
+ purchase = self.env['purchase.order'].search([
+ ('name', '=', stock_picking.group_id.name),
+ ])
+ if not stock_picking.approval_return_status == 'approved' and purchase.invoice_ids:
+ raise UserError('Harus Approval Accounting AP untuk melakukan Retur')
return res \ No newline at end of file