diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-12-28 13:23:49 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-12-28 13:23:49 +0700 |
| commit | 08724b92174a216a64b382012e83e45c16b326e7 (patch) | |
| tree | 081aa2f24c388f62f26de6e8d4bc8ca690b1e235 | |
| parent | c6dbde248d5a9c12f7e1f53ce4596f6b5611750a (diff) | |
add validation on sale order Tempo 3 months must be margin 25
| -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 |
