diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-11-14 15:04:58 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-11-14 15:04:58 +0700 |
| commit | a2fe5cf62932ee4f112fd2f126ca2ee29036046a (patch) | |
| tree | e2813d1766dcfbdce3931767947b507cd7a3e67b | |
| parent | c6ace1b75f1c93e1706cfa6f82b7f34513b209f5 (diff) | |
change method of update solr flag
| -rw-r--r-- | indoteknik_custom/models/product_pricelist.py | 10 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 28 | ||||
| -rwxr-xr-x | indoteknik_custom/models/stock_vendor.py | 8 | ||||
| -rwxr-xr-x | indoteknik_custom/models/x_manufactures.py | 12 | ||||
| -rwxr-xr-x | indoteknik_custom/views/product_template.xml | 1 |
5 files changed, 46 insertions, 13 deletions
diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py index b70eb6e6..5573ea55 100644 --- a/indoteknik_custom/models/product_pricelist.py +++ b/indoteknik_custom/models/product_pricelist.py @@ -10,3 +10,13 @@ class ProductPricelist(models.Model): start_date = fields.Datetime(string='Start Date') end_date = fields.Datetime(string='End Date') + +class ProductPricelistItem(models.Model): + _inherit = 'product.pricelist.item' + + @api.onchange('fixed_price','price_discount') + def update_solr_flag(self): + for item in self: + if item.product_id.product_tmpl_id.solr_flag == 1: + item.product_id.product_tmpl_id.solr_flag = 2 +
\ No newline at end of file diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 4c8f664d..5d34fbc8 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -34,10 +34,16 @@ class ProductTemplate(models.Model): virtual_qty = fields.Float(string='Virtual Qty', default=0) solr_flag = fields.Integer(string='Solr Flag', default=0) - def write(self, vals): - if 'solr_flag' not in vals and self.solr_flag == 1: - vals['solr_flag'] = 2 - return super().write(vals) + # def write(self, vals): + # if 'solr_flag' not in vals and self.solr_flag == 1: + # vals['solr_flag'] = 2 + # return super().write(vals) + + @api.onchange('name','default_code','x_manufacture','product_rating','website_description','image_1920','weight','public_categ_ids') + def update_solr_flag(self): + for tmpl in self: + if tmpl.solr_flag == 1: + tmpl.solr_flag = 2 def _compute_qty_stock_vendor(self): for product_template in self: @@ -150,13 +156,13 @@ class ProductProduct(models.Model): help="Stock Vendor") solr_flag = fields.Integer(string='Solr Flag', default=0) - def write(self, vals): - if 'solr_flag' not in vals: - for variant in self: - if variant.solr_flag == 1: - variant.product_tmpl_id.solr_flag = 2 - vals['solr_flag'] = 2 - return super().write(vals) + # def write(self, vals): + # if 'solr_flag' not in vals: + # for variant in self: + # if variant.solr_flag == 1: + # variant.product_tmpl_id.solr_flag = 2 + # vals['solr_flag'] = 2 + # return super().write(vals) def _compute_web_price(self): for product in self: diff --git a/indoteknik_custom/models/stock_vendor.py b/indoteknik_custom/models/stock_vendor.py index 79c95781..1a6b4a64 100755 --- a/indoteknik_custom/models/stock_vendor.py +++ b/indoteknik_custom/models/stock_vendor.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import fields, models, api import logging _logger = logging.getLogger(__name__) @@ -29,3 +29,9 @@ class StockVendor(models.Model): for template in templates: template.virtual_qty = template.qty_stock_vendor or 0 _logger.info("Update Stock Product Template %s : %s" % (template.id, template.virtual_qty)) + + @api.onchange('quantity') + def update_solr_flag(self): + for stock in self: + if stock.product_variant_id.product_tmpl_id.solr_flag == 1: + stock.product_variant_id.product_tmpl_id.solr_flag = 2 diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py index b32d257d..dae37668 100755 --- a/indoteknik_custom/models/x_manufactures.py +++ b/indoteknik_custom/models/x_manufactures.py @@ -1,4 +1,4 @@ -from odoo import models, fields +from odoo import models, fields, api class XManufactures(models.Model): @@ -35,3 +35,13 @@ class XManufactures(models.Model): ('sparepart', 'Spare Part') ], string="Jenis Produk") x_short_desc = fields.Text(string="Short Description") + + @api.onchange('x_name','image_promotion_1','image_promotion_2') + def update_solr_flag(self): + for manufacture in self: + templates = self.env['product.template'].search([ + ('x_manufacture', '=', manufacture.id) + ]) + for template in templates: + if template.solr_flag == 1: + template.solr_flag = 2 diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index 576e2623..d97359b6 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -46,6 +46,7 @@ <field name="last_calculate_rating" attrs="{'readonly': [('type', '=', 'product')]}"/> <field name="product_rating"/> <field name="web_price_sorting" attrs="{'readonly': [('type', '=', 'product')]}"/> + <field name="solr_flag"/> </field> </field> </record> |
