hello,
how can i filter my One2many field base on Many2one field?
exemple, i have 2 classes like:
--------begin-----------
class btp_caution(models.Model):
_name = "btp.caution"
_description = "Les cautions"
name = fields.Char(string='Libellé caution', required=True)
nemero = fields.Char(string='Numéro caution')
banque_id = fields.Many2one('btp.banque', 'Banque')
projet_id = fields.Many2one('btp.projet', 'Projet')
etat_caution = fields.Many2one('btp.etatcaution', 'etat_caution_')
class btp_etatcaution(models.Model):
_name = "btp.etatcaution"
_description = "voir les etats des differentes cautions filtres par banque et par projet/marche"
_auto = 'False'
name = fields.Char('Name')
banque_id = fields.Many2one('btp.banque', 'Banque')
projet_id = fields.Many2one('btp.projet', 'Projet')
ligne_caution_etat = fields.One2many('btp.caution', 'etat_caution', 'etat_caution')
--------end-----------
and i have view related to this last one (btp.etatcaution) like:
--------begin-----------
<record id="view_btp_etatcaution_form" model="ir.ui.view">
<field name="name">etatcaution</field>
<field name="model">btp.etatcaution</field>
<field name="arch" type="xml">
<form string="etatcaution" class="oe_form_configuration" create="false">
<sheet>
<group>
<field name="banque_id" class="oe_inline"/>
<field name="projet_id" class="oe_inline"/>
</group>
</sheet>
<notebook>
<page string="Etat caution">
<div class="row"><div class="col-xs-12 text-muted">
<field name="ligne_caution_etat" >
<tree editable="bottom" string="Etat caution" create="false">
<field name="name"/>
<field name="nemero"/>
<field name="banque_id"/>
<field name="projet_id"/>
</tree>
</field>
</div></div>
</page>
</notebook>
</form>
</field>
</record>
<record id="action_etatcaution" model="ir.actions.act_window">
<field name="name">etatcaution</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">btp.etatcaution</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="res_id">1</field>
<field name="view_id" ref="view_btp_etatcaution_form"/>
</record>
--------end-----------
how can i do to filter my notebook data in oder to return only record which banque_id and projet_id are choosed in the form view?
e.g : the value of banque_id and projet_id in all notebook lines should be the same that those we have shoosed in <sheet> .... </sheet>
Read this documentation for odoo customization: https://learnopenerp.tumblr.com/