I think that the current way for set sequences on configuration models need Multivalue, CompanyMultiValueMixin, CompanyValueMixin, default_func but this can be redesign to an easy way, removing indeed ModelSingleton
I propose not use ModelSingleton and Multivalue fields in configuration Models, instead set company by each configuration record, in other words it is simply replaced by ModelView and ModelSQL, using for example following structure:
For me is a simple solution, easy understand, easy coding, easy debugging, easy to migrate, works with multiple companies, and the moment does not require API changes
Ok, I think those drawbacks can be solved, I am not expert, but I try search a solution for each one:
The start idea is not remove Multivalue feature of core Tryton, just in several configuration models
We can add some class style “ModelSingleton” or any variable in setup or register that automatic create a record configuration when is missing one, or the company is created.
We can add company “Unique” sql constraint to configuration model, with this avoid duplicate company configuration.
I dont know in which case context is not setted, but the piece code can be modified for above example:
@classmethod
def get_configuration(cls, company=None):
if not company:
company = Transaction().context.get(‘company’)
config, = cls.search([
(‘company’, ‘=’, company)
])
return config
Ok but we can add a new cache attribute to this models, for example:
class MyModelConfiguration(ModelSQL, ModelView): __cache = True
company = fields.Many2One(…) # required=True
sequence_foo = fields.Many2One(‘ir.sequence’,…)