summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_pricelist.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/purchase_pricelist.py')
-rwxr-xr-xindoteknik_custom/models/purchase_pricelist.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py
index 4ea2b9ef..419ca8e0 100755
--- a/indoteknik_custom/models/purchase_pricelist.py
+++ b/indoteknik_custom/models/purchase_pricelist.py
@@ -1,5 +1,7 @@
-from odoo import models, fields, api
-
+from odoo import fields, models, api, _
+from odoo.exceptions import AccessError, UserError, ValidationError
+from datetime import datetime, timedelta
+from pytz import timezone
class PurchasePricelist(models.Model):
_name = 'purchase.pricelist'
@@ -8,8 +10,20 @@ class PurchasePricelist(models.Model):
name = fields.Char(string='Name', compute="_compute_name")
product_id = fields.Many2one('product.product', string="Product", required=True)
vendor_id = fields.Many2one('res.partner', string="Vendor", required=True)
- product_price = fields.Float(string='Price', required=True)
+ product_price = fields.Float(string='Human Price', required=True)
+ system_price = fields.Float(string='System Price', required=True)
+ human_last_update = fields.Datetime(string='Human Update')
+ system_last_update = fields.Datetime(string='System Update')
@api.depends('product_id', 'vendor_id')
def _compute_name(self):
self.name = self.vendor_id.name + ', ' + self.product_id.name
+
+ @api.constrains('product_price','system_price','vendor_id','product_id')
+ def _contrains_product_price(self):
+ current_time = fields.Datetime.now(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S')
+ update_by = self._context.get('update_by')
+ if update_by == 'system':
+ self.system_last_update = current_time
+ else:
+ self.human_last_update = current_time