Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
1237 Weergaven
class PharmacySettings(models.TransientModel):
_inherit = 'res.config.settings'

product_group = fields.Many2one('product.group', string='Product Group')

def set_values(self):
res = super(PharmacySettings, self).set_values()
self.env['ir.config_parameter'].set_param('custom_pharmacy_invoice_view.product_group', self.product_group)
return res

@api.model
def get_values(self):
res = super(PharmacySettings, self).get_values()
ICPsudo = self.env['ir.config_parameter'].sudo()
groups = ICPsudo.get_param('custom_pharmacy_invoice_view.product_group')
res.update(
product_group=groups

)
print(res)

When i wnat to save selection field value the this error occured:

psycopg2.errors.InvalidTextRepresentation: invalid input syntax for integer: "product.group(1,)"
LINE 1: ...FROM "product_group" WHERE "product_group".id IN ('product.g...

How can I solve it Please help me 

Avatar
Annuleer
Beste antwoord

In setting the params, you should pass the ID of the group but you are passing the recordset which is causing the error.
Try this:

self.env['ir.config_parameter'].set_param('custom_pharmacy_invoice_view.product_group', self.product_group.id) # Pass ID like this: self.product_group.id
Avatar
Annuleer