diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-12-22 13:36:43 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-12-22 13:36:43 +0700 |
| commit | 74bc0544d9789479f599e808930e01ecea7fbf22 (patch) | |
| tree | ef11ccc1620ab31ee1b560c8b16f0552041a7742 /fixco_custom/models/sale.py | |
| parent | b03b5e7d3ab83db6f26610490fc2a4e7dc4d3d9c (diff) | |
push
Diffstat (limited to 'fixco_custom/models/sale.py')
| -rwxr-xr-x | fixco_custom/models/sale.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index 4a1b79e..b7cbe17 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -5,12 +5,13 @@ from odoo.exceptions import UserError class SaleOrder(models.Model): _inherit = "sale.order" - carrier = fields.Char(string='Shipping Method', required=True) - invoice_mp = fields.Char(string='Invoice Marketplace', required=True) - order_reference = fields.Char(string='Order Reference', required=True) - address = fields.Char('Address') - channel = fields.Char('Channel') - note_by_buyer = fields.Char('Note By Buyer') + carrier = fields.Char(string='Shipping Method', required=True, copy=False) + invoice_mp = fields.Char(string='Invoice Marketplace', required=True, copy=False) + order_reference = fields.Char(string='Order Reference', required=True, copy=False) + address = fields.Char('Address', copy=False) + channel = fields.Char('Channel', copy=False) + note_by_buyer = fields.Char('Note By Buyer', copy=False) + source = fields.Selection([('manual', 'Manual'), ('ginee', 'Ginee')], string='Source', default='manual', copy=False) count_payment = fields.Integer('Count Payment', compute='_compute_count_payment') @@ -107,15 +108,16 @@ class SaleOrder(models.Model): def _check_duplicate_order_id(self): for rec in self: - so_duplicate = self.search([ - '|', - ('order_reference', '=', rec.order_reference), - ('invoice_mp', '=', rec.invoice_mp), - ('id', '!=', rec.id), - ], limit=1) + if rec.order_reference and rec.invoice_mp: + so_duplicate = self.search([ + '|', + ('order_reference', '=', rec.order_reference), + ('invoice_mp', '=', rec.invoice_mp), + ('id', '!=', rec.id), + ], limit=1) - if so_duplicate: - raise UserError(f'Order Id tersebut sudah digunakan di so {so_duplicate.name}') + if so_duplicate: + raise UserError(f'Order Id tersebut sudah digunakan di so {so_duplicate.name}') # def open_form_multi_create_invoices(self): # action = self.env['ir.actions.act_window']._for_xml_id('fixco_custom.action_sale_order_multi_invoices') @@ -193,6 +195,8 @@ class SaleOrder(models.Model): def action_confirm(self): for order in self: + if order.source == 'manual' and self.env.user.id not in [9, 10, 15]: + raise UserError("Anda tidak memiliki akses untuk approve SO manual") order._check_duplicate_order_id() res = super(SaleOrder, self).action_confirm() return res |
