|
@ -19,7 +19,7 @@ |
|
|
# If not, see <http://www.gnu.org/licenses/>. |
|
|
# If not, see <http://www.gnu.org/licenses/>. |
|
|
# |
|
|
# |
|
|
############################################################################# |
|
|
############################################################################# |
|
|
from odoo import fields, models |
|
|
from odoo import api, fields, models |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProductTemplate(models.Model): |
|
|
class ProductTemplate(models.Model): |
|
@ -31,9 +31,19 @@ class ProductTemplate(models.Model): |
|
|
help="Specify if the product is a mobile part or not.") |
|
|
help="Specify if the product is a mobile part or not.") |
|
|
brand_name = fields.Many2one('mobile.brand', string="Brand", |
|
|
brand_name = fields.Many2one('mobile.brand', string="Brand", |
|
|
help="Select a mobile brand for the part.") |
|
|
help="Select a mobile brand for the part.") |
|
|
|
|
|
allowed_model_ids = fields.Many2many('brand.model', compute='_compute_allowed_model_ids') |
|
|
model_name = fields.Many2one('brand.model', string="Model Name", |
|
|
model_name = fields.Many2one('brand.model', string="Model Name", |
|
|
domain="[('mobile_brand_name','=',brand_name)]", |
|
|
|
|
|
help="Select a model for the part.") |
|
|
help="Select a model for the part.") |
|
|
model_colour = fields.Char(string="Colour", help="Colour for the part.") |
|
|
model_colour = fields.Char(string="Colour", help="Colour for the part.") |
|
|
extra_descriptions = fields.Text(string="Note", help="Extra description " |
|
|
extra_descriptions = fields.Text(string="Note", help="Extra description " |
|
|
"for the part.") |
|
|
"for the part.") |
|
|
|
|
|
|
|
|
|
|
|
@api.depends('brand_name') |
|
|
|
|
|
def _compute_allowed_model_ids(self): |
|
|
|
|
|
for rec in self: |
|
|
|
|
|
if rec.brand_name: |
|
|
|
|
|
rec.allowed_model_ids = self.env['brand.model'].search([ |
|
|
|
|
|
('mobile_brand_name', '=', rec.brand_name.id) |
|
|
|
|
|
]).ids |
|
|
|
|
|
else: |
|
|
|
|
|
rec.allowed_model_ids = self.env['brand.model'].search([]).ids |
|
|