I have the custom field:
class Sale(metaclass=PoolMeta):
custom_field = fields.Many2One('custom.model', "CUSTOM FIELD")
def get_production(self):
production = super().get_production()
production.custom_field = self.custom_field
return production
On creating the shipment I want the shipment to use a sequence based on that field, somethink like this:
class Production(metaclass=PoolMeta):
__name__ = 'production'
custom_field = fields.Many2One('custom.model', "CUSTOM FIELD")
@classmethod
def create(cls, vlist):
pool = Pool()
Config = pool.get('production.configuration')
vlist = [x.copy() for x in vlist]
config = Config(1)
default_company = cls.default_company()
for values in vlist:
if values.get('number') is None:
values['number'] = config.get_multivalue(
'production_sequence',
custom_field=values.get('custom_field'),
company=values.get('company', default_company)).get()
productions = super().create(vlist)
return productions
But I don’t know how to extend sequence or config to allow this.
Also If there are other simple/clean solutions feel free to suggest.