I created an object for show quants of each partner(locate of products that are in the user's hands)
and I set a view for show this.(a form that have one field "partner_id", and have a action button for show quants with name "emp_open_quants")
class PRQuants(models.Model):
_name = "product.requisition.emp.quants"
_description = "Product Requisition Employee's Quants"
_inherit = ['mail.thread']
_order = 'partner_id'
partner_id = fields.Many2one('res.partner', 'Partner')
now, I want when in partner form in my module, click on button"emp_open_quants", I see only this partner's quants.so I do this: (but does'nt work)
<record model="ir.actions.act_window" id="emp_open_quants">
<field name="name">Quants</field>
<field name="context">{'search_default_owner_id': partner_id}</field>
<field name="res_model">stock.quant</field>
</record>
<record id="view_pr_emp_quants_form" model="ir.ui.view">
<field name="name">pr.emp.quants.form</field>
<field name="model">product.requisition.emp.quants</field>
<field name="priority">10</field>
<field name="arch" type="xml">
<form string="Employee's Assets(Quants)">
<sheet>
<div class="oe_button_box" name="button_box">
<button name="%(emp_open_quants)d" icon="fa-arrows" class="oe_stat_button" string="Locatee" type="action" />
</div>
<group name="main_group">
<group>
<field name="partner_id"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
in below context , I have error that "partner_id" is not defined:
<field name="context">{'search_default_owner_id': partner_id}</field>
{'search_default_owner_id': 23}
How to to use context: http://learnopenerp.blogspot.com/2018/01/get-parent-form-value-in-one2many-form.html