diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-10-25 08:47:36 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-10-25 08:47:36 +0700 |
| commit | 9fa80c62cdffec5b91aaf2a2899d70d0f507c2e4 (patch) | |
| tree | 93ae8d82f774345f650bc8d072dea759c6e33363 /indoteknik_custom/models/purchase_order.py | |
| parent | a21c5fe37529b2d2259d3b86d8e98730b2bc8513 (diff) | |
| parent | a7be93f4825967807f12e6bfbebcf090af8500fa (diff) | |
Merge branch 'production' into iman/switch-account
# Conflicts:
# indoteknik_api/controllers/api_v1/user.py
# indoteknik_custom/models/user_company_request.py
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 8a47482a..f924174a 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -70,6 +70,7 @@ class PurchaseOrder(models.Model): bills_dp_id = fields.Many2one('account.move', string='Bills DP') grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total') total_margin_match = fields.Float(string='Total Margin Match', compute='_compute_total_margin_match') + approve_by = fields.Many2one('res.users', string='Approve By') def _compute_total_margin_match(self): for purchase in self: @@ -503,12 +504,15 @@ class PurchaseOrder(models.Model): current_time = datetime.now() self.check_ppn_mix() # self.check_data_vendor() + + if self.amount_untaxed >= 50000000 and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): + raise UserError("Hanya Merchandiser yang bisa approve") - if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.is_purchasing_manager and not self.env.user.is_leader: - raise UserError("Beda Margin dengan Sales, harus approval Manager") + if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser') and not self.env.user.is_leader: + raise UserError("Beda Margin dengan Sales, harus approval Merchandise") if not self.from_apo: - if not self.sale_order_id and not self.env.user.is_purchasing_manager and not self.env.user.is_leader: - raise UserError("Tidak ada link dengan SO, harus approval Manager") + if not self.sale_order_id and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser') and not self.env.user.is_leader: + raise UserError("Tidak ada link dengan SO, harus approval Merchandise") send_email = False self.add_product_to_pricelist() @@ -530,7 +534,7 @@ class PurchaseOrder(models.Model): self._send_mail() if self.revisi_po: - delta_time = current_time - timedelta(days=2) + delta_time = current_time - timedelta(days=1) delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') self.date_approve = delta_time @@ -538,6 +542,7 @@ class PurchaseOrder(models.Model): self.po_status = 'menunggu' self.calculate_line_no() + self.approve_by = self.env.user.id # override date planned added with two days leadtime = self.partner_id.leadtime @@ -634,7 +639,9 @@ class PurchaseOrder(models.Model): template.send_mail(self.id, force_send=True) def po_approve(self): - if self.env.user.is_leader or self.env.user.is_purchasing_manager: + if self.amount_untaxed >= 50000000 and not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): + raise UserError("Hanya Merchandiser yang bisa approve") + if self.env.user.is_leader or self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): raise UserError("Bisa langsung Confirm") elif self.total_percent_margin == self.total_so_percent_margin and self.sale_order_id: raise UserError("Bisa langsung Confirm") |
