diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-07-22 10:06:53 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-07-22 10:06:53 +0700 |
| commit | ca84cc359ed7535474aafac877843374baac5414 (patch) | |
| tree | 95413ed7e4b41d6676e9403cf9e23cdc6a90881c | |
| parent | e2d42ebca210467698f163558e6e4390dcecaae9 (diff) | |
add compute web price in product template
| -rw-r--r-- | indoteknik_custom/models/product_template.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 61cf09e2..348bda99 100644 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -16,18 +16,28 @@ class ProductTemplate(models.Model): ) x_lazada = fields.Text(string="Lazada") x_tokopedia = fields.Text(string="Tokopedia") + web_price = fields.Float( + 'Web Price', compute='_compute_web_price', + digits='Product Price', inverse='_set_product_lst_price', + help="Web Price with pricelist_id = 1") + + def _compute_web_price(self): + for template in self: + product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)],limit=1) + product_pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 1),('product_id', '=', product.id)],limit=1) + template.web_price = product_pricelist_item.fixed_price class ProductProduct(models.Model): _inherit = "product.product" web_price = fields.Float( - 'Web Price', compute='_compute_product_discount_price', + 'Web Price', compute='_compute_web_price', digits='Product Price', inverse='_set_product_lst_price', help="Web Price with pricelist_id = 1") qty_stock_vendor = fields.Float( 'Qty Stock Vendor', compute='_compute_stock_vendor', help="Stock Vendor") - def _compute_product_discount_price(self): + def _compute_web_price(self): for product in self: product_pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 1),('product_id', '=', product.id)],limit=1) product.web_price = product_pricelist_item.fixed_price |
