Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] rma_account: change account_move_line_id domain to make search more efficient #460

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading