diff options
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 1b51f44b..12526131 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1,5 +1,5 @@ from odoo import fields, models, api, _ -from odoo.exceptions import UserError +from odoo.exceptions import UserError, ValidationError from datetime import datetime import logging, random, string, requests, math, json, re @@ -365,10 +365,15 @@ class SaleOrder(models.Model): order.is_warning = False def _validate_order(self): + if self.payment_term_id.id == 31 and self.total_percent_margin < 25: + raise UserError("Total Margin Belum mencapai 25%") + if self.warehouse_id.id != 8: #GD Bandengan raise UserError('Gudang harus Bandengan') + if self.state not in ['draft', 'sent']: raise UserError("Status harus draft atau sent") + if not self._validate_npwp(): raise UserError("Isi NPWP Dengan Benar!") @@ -379,8 +384,8 @@ class SaleOrder(models.Model): def sale_order_approve(self): self.check_due() + self._validate_order() for order in self: - order._validate_order() order.order_line.validate_line() partner = order.partner_id.parent_id or order.partner_id |
