progressdll
progressdll

Reputation: 374

filter tree view of header model on base of values of the detail model

I have a model 'purchase_approval_item' with an invoice_id

multiple people approve the invoice and they are registered in the model 'purchase_approval_item_line'

Now i need to show the 'purchase_approval_item' in a tree view, but filter is for the logged in user.

I want to add one2many field in 'purchase_approval_item', approved_by_ids which should be the uids of the approvers. And i want to use that one2many field to filter the treeview.

How can i do this with the openerp framework?

Upvotes: 1

Views: 1518

Answers (2)

Atul Arvind
Atul Arvind

Reputation: 16763

You can also add a record rule. which will let user to see only record approved by him/her in tree view.

<record model="ir.rule" id="resource_approved_record">
    <field name="name">See Own Approved record</field>
    <field name="model_id" ref="model_purchase_approval_item"/>
    <field name="domain_force">[('approved_by_ids', 'in', [user.id]])]</field>
</record>

Upvotes: 2

Daniel Reis
Daniel Reis

Reputation: 13382

You want to filter the purchase_approval_item tree to have only the records where the approved_by_ids one2many field contains a certain a user - probably the current one.

You should have a search view for your purchase_approval_item model, with:

<filter domain="[('approved_by_ids', 'in', [uid])]" 
        name="filter_my_approvals" string="My Approvals" />

Upvotes: 2

Related Questions