How to pass datas to One2many fields in odoo 14
The One2many filed is used for making a field which contain many fields.This field consist of another models.For creating a One2many filed we have to define a new model(sub model).The main model’s One2many field is used to store values to that sub model.
DATA PASSING TO ONE2MANY FIELD IN ODOO 14
Here we have to pass datas from sale order to our new model.
1: first you need to create a new class in py file.
in Practical case:
eg: class SalesOne(models.Model):
_name=’sales.one’
from_data=fields.Date(“From Date”)
to_date = fields.Date(“to Date”)
invoice = fields.One2many(‘sales.two’,’conn’)
class sales_invoice(models.Model):
_name = ‘sales.invoice’
conn = fields.Many2one(‘sales.invoice.form’)
entry_date = fields.Date(“Entry Date”)
system_date = fields.Date(“System Date”)
invoice_no = fields.Char(‘INV No’)
party_name = fields.Char(“Party Name”)
invoice is the one2many field and conn is the field we use to connect with the One2many .