Override many2one with many2many

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Override many2one with many2many



I try to override many2one field with many2many


property_product_pricelist = fields.Many2many('product.pricelist',
string="Sale Pricelist",
help="This pricelist will be used, instead of the default one, for sales to the current partner")



and i get this error when try to save values


File "/home//workspace/odoo-9.0/openerp/models.py", line 5384, in _browse
env.prefetch[cls._name].update(ids)
TypeError: unhashable type: 'list'



also i tryid like this


property_product_pricelist = fields.Many2many('product.pricelist', column1='partner_id', column2='pricelist_id')



but get


ProgrammingError: column product_pricelist_res_partner_rel.pricelist_id does not exist



LINE 1: SELECT product_pricelist_res_partner_rel.pricelist_id, produ...





I would suggest you not to do that because if a Many2one field already exists, it must be used at many different places and you will have errors everywhere, because a singleton is expected instead of a list. You should create another field instead.
– Harlan
Aug 7 at 6:01





What you are doing is bad because you will break the logic.Ask you the question why I need a many2many field ?
– WaKo
Aug 7 at 13:17


why I need a many2many field ?




1 Answer
1



Best solution I came up with.


multiply_pricelists_ids = fields.Many2many(
'product.pricelist', string='Multiply Pricelists')

@api.onchange('property_product_pricelist')
@api.multi
def pricelist_change(self):
self.multiply_pricelists_ids = self.property_product_pricelist






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard