Skip to Content
Menu
This question has been flagged
1 Atsakyti
1235 Rodiniai
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 

Portretas
Atmesti
Best Answer

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
Portretas
Atmesti