Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1242 มุมมอง
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 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง