Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2624 Näkymät

I've modified sale order line to include another field. I'm trying to access the value of that field in another model. Below is a simplified version of my code.
The error that I am getting is:

KeyError: 'state_id'



class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
state_id = fields.Many2one('res.country.state', string='Jurisdiction')
compliance_workflow_id = fields.Many2one('compliance.workflow', string='Workflow')

class  ComplianceWorkflow(models.Model):
_name = 'compliance.workflow'
_description = 'Compliance workflow'

order_id = fields.Many2one('sale.order', string='Order')
order_line_id = fields.Many2one('sale.order.line', string='Order line')
state_id = fields.Many2one('res.country.state', related='order_line_id.state_id', string="Jurisdiction")
Where am I going wrong here?
Avatar
Hylkää

Try storing sate_id , rest seem alright it should work

Tekijä

What do you mean by storing state_id? I get this error when I start the server. The database can't be initialized because of the error.

can you upgrading the module from the terminal and see