sorry for bothering you guys! just started using odoo a couple of days ago and am facing kinda a silly thing so forgive my newbie question!
created a one2many relation btw my model and account.invoice
onchange method i get invoices of a specific res.partner
after debugging i can see that i got the invoices list but i cant display then on GUI
here you are my code:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class account_invoice(models.Model):
_inherit = 'account.invoice'
mtoField = fields.Many2one('mynamespace', ondelete='cascade',required=True, string = 'Field Name')
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CustomModel(models.Model):
_name='mynamespace'
invoices= fields.One2many('account.invoice','mtqField',string='Invoices',readonly=True)
client = fields.Many2one('res.partner', string ='Client', required=True)
@api.onchange('client')
def _OnDataChanged(self):
foundInvoices = self.env['account.invoice'].search([['partner_id', '=', self.client.id]])
ids=[]
for inv in foundInvoices:
ids.append(inv.id)
return{'value' : {'invoices' : ids}}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
<record model="ir.ui.view" id="view_mymodel_form">
<field name="name">mymodel.form</field>
<field name="model">mynamespace</field>
<field name="arch" type="xml">
<form>
<sheet>
<group string ="Invoice List">
<field name="invoices">
<tree string = "Invoices List in Date Range">
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>