Hi, Please help me.
Sale order and contract form communicate with through the contract Id field.
How send order line to contract line and display form contract?
I used the following code but it doesn't work.
class SaleOrder(models.Model):
_name = "sale.order"
contract_id = fields.Many2one('contract',string='relation field')
@api.multi
def sent_item(self): line_vals = []
for line in self.order_line:
line_vals.append([(0, 0, {'product': line.product_id.id,'saleorder_number': self.id})])
domain = [('contract_id', 'in', self.mapped('contract_id.id'))]
contract_item = self.env['contract_item'].search(domain)
record = contract_item.create({
'c_items': line_vals
})
self.contract_id.c_items = record.id