from odoo import models, fields, api class XManufactures(models.Model): _name = 'x_manufactures' _description = "Manufactures" _rec_name = "x_name" x_name = fields.Char(string="Name") x_description = fields.Html(string="Description") x_logo_manufacture = fields.Binary(string="Logo Manufacture") x_logo_manufacture_128 = fields.Image("Image 128", related="x_logo_manufacture", max_width=128, max_height=128, store=True) image_promotion_1 = fields.Binary(string="Promotion Image 1") image_promotion_2 = fields.Binary(string="Promotion Image 2") x_manufacture_level = fields.Selection([ ('prioritas', 'Prioritas'), ('gold', 'Gold'), ('silver', 'Silver') ], string="Manufacture Level") x_manufacture_product = fields.One2many( comodel_name="product.template", inverse_name="x_manufacture", string="Relasi Produk" ) x_manufacture_service_center = fields.Many2many("res.partner", string="Service Center") x_manufactures_banners = fields.One2many( comodel_name="x_banner.banner", inverse_name="x_relasi_manufacture", string="Relasi Manufacture Banner" ) x_negara_asal = fields.Char(string="Negara Asal") x_produk_aksesoris_sparepart = fields.Selection([ ('produk', 'Produk'), ('aksesoris', 'Aksesoris'), ('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