diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-11-14 13:58:59 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-11-14 13:58:59 +0700 |
| commit | 0886dcb783f8c57859e2856c7936015b7bba3fa5 (patch) | |
| tree | 0c4e99da0fe0e84be631cb401f3faf790ee38108 | |
| parent | 0b85c98761260dd93b70fa429340c4edbf5154b1 (diff) | |
return approval if just have invoice only
| -rw-r--r-- | indoteknik_custom/models/stock_picking_return.py | 12 |
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 |
