diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-11-21 09:24:56 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-11-21 09:24:56 +0700 |
| commit | 5a71f4543a265562abc36630d16059f9db92d056 (patch) | |
| tree | 63a7ba570ae27a9226cd14b572e197d996c49661 | |
| parent | 1323859c604568f95e518b97e8bfed7d922debe3 (diff) | |
cr stock_picking
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 071e3dfe..f17e12b7 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -442,29 +442,31 @@ class StockPicking(models.Model): for pick in self: if self.env.user.is_accounting: pick.approval_return_status = 'approved' - else: - if self.picking_type_code == 'outgoing': - if self.env.user.id in [3988, 3401, 20]: - action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') - action['context'] = { - 'picking_ids': [x.id for x in self] - } - return action - elif not self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin: - raise UserError('Harus Purchasing yang Ask Return') - else: - raise UserError('Harus Sales Admin yang Ask Return') - elif self.picking_type_code == 'incoming': - if self.env.user.has_group('indoteknik_custom.group_role_purchasing'): - action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') - action['context'] = { - 'picking_ids': [x.id for x in self] - } - return action - elif not self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin: - raise UserError('Harus Sales Admin yang Ask Return') - else: - raise UserError('Harus Purchasing yang Ask Return') + continue + + action_context = { + 'picking_ids': [x.id for x in self] + } + + if self.picking_type_code == 'outgoing': + if self.env.user.id in [3988, 3401, 20] or ( + self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin + ): + return self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard', context=action_context) + elif not self.env.user.has_group('indoteknik_custom.group_role_purchasing') and 'Return of' in self.origin: + raise UserError('Harus Purchasing yang Ask Return') + else: + raise UserError('Harus Sales Admin yang Ask Return') + + elif self.picking_type_code == 'incoming': + if self.env.user.has_group('indoteknik_custom.group_role_purchasing') or ( + self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin + ): + return self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard', context=action_context) + elif not self.env.user.id in [3988, 3401, 20] and 'Return of' in self.origin: + raise UserError('Harus Sales Admin yang Ask Return') + else: + raise UserError('Harus Purchasing yang Ask Return') def calculate_line_no(self): |
