Skip to content

Commit

Permalink
[IMP] rma_account: change account_move_line_id domain to make search …
Browse files Browse the repository at this point in the history
…more efficient
  • Loading branch information
mariadforgeflow authored and JordiBForgeFlow committed Oct 2, 2023
1 parent b5a55ac commit ea157df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 14 additions & 0 deletions rma_account/models/rma_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ def _compute_refund_count(self):
store=True,
)

commercial_partner_id = fields.Many2one(
"res.partner",
string="Commercial Entity",
store=True,
readonly=True,
compute="_compute_commercial_partner_id",
ondelete="restrict",
)

@api.depends("partner_id")
def _compute_commercial_partner_id(self):
for rma_line in self:
rma_line.commercial_partner_id = rma_line.partner_id.commercial_partner_id

@api.onchange("product_id", "partner_id")
def _onchange_product_id(self):
"""Domain for sale_line_id is computed here to make it dynamic."""
Expand Down
12 changes: 6 additions & 6 deletions rma_account/views/rma_order_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<field name="inherit_id" ref="rma.view_rma_line_supplier_form" />
<field name="arch" type="xml">
<group name="main_info" position="inside">
<field name="commercial_partner_id" invisible="1" />
<field
name="account_move_line_id"
options="{'no_create': True}"
context="{'rma': True}"
domain="[('move_id.move_type', 'not in', ['entry','out_invoice','out_refund']), '|',
('move_id.partner_id', '=', partner_id),
('move_id.partner_id', 'child_of', partner_id)]"
domain="[('move_id.move_type', 'not in', ['entry','out_invoice','out_refund']),
('partner_id', '=', commercial_partner_id)]"
attrs="{'invisible':[('type', '!=', 'supplier')]}"
/>
</group>
Expand Down Expand Up @@ -46,13 +46,13 @@
</button>
</button>
<group name="main_info" position="inside">
<field name="commercial_partner_id" invisible="1" />
<field
name="account_move_line_id"
options="{'no_create': True}"
context="{'rma': True}"
domain="[('move_id.move_type', '!=', 'entry'), '|',
('move_id.partner_id', '=', partner_id),
('move_id.partner_id', 'child_of', partner_id)]"
domain="[('move_id.move_type', '!=', 'entry'),
('partner_id', '=', commercial_partner_id)]"
attrs="{'invisible':[('type', '!=', 'customer')]}"
/>
</group>
Expand Down

0 comments on commit ea157df

Please sign in to comment.