Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
1217 Näkymät
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
Hylkää
Paras vastaus

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
Hylkää