Hello!
I need to add two selection fields in products: one for manufacturer (For example: LG, Samsung) and another selection field for the model that would depend from the selected manufacturer. For example, if we selected LG, then in models field we'll see only models for LG, and if Samsung is selected, then only models for samsung we can select in models field.
I'm trying to get value of selection field, but always get ony None instead:
from odoo import models, fields, api
class ProductManufacturer(models.Model):
_inherit = 'product.template'
def get_manufactures(self):
manufactures = []
raw_data = self.env['product.manufacturer.model'].search([])
for rec in raw_data:
manufactures.append((rec.manufacturer_id, rec.product_manufacturer))
return manufactures
def get_selected_value(self):
print('ALARM!')
print('ALARM', dict(self._fields['product_manufacturers'].selection(self)).get(self.type))
return ('one', 'ONE')
product_manufacturers = fields.Selection(get_manufactures,
string='Manufacturer', required=True)
product_models = fields.Selection(get_selected_value)
My function get_selected_value for testing, also alarms there for testing too ;)
Can anybody tell how can I get the value from selection field?
I'll be grateful for any help.