Skip to content
Snippets Groups Projects
Commit c34e0200 authored by Victor Piryns (pivi)'s avatar Victor Piryns (pivi)
Browse files

[FIX] sale: display related SO for intermediate contacts


Current behaviour:
In the context of a multilevel contact hierarchy, if a contact is creating an SO, only that contact and it's commercial partner (usually the first company when going up in hierarchy from that contact) can see the SO.
The other contacts that are in that hierarchy could see the number of related SO on the smart button, but once clicking on it, no SO were shown.

Expected behaviour:
Every direct or indirect parent of a contact should be able to see the SO, as shown in the smart button count.

Steps to reproduce:
- Create 3 contacts with the following hierarchy: Company -> Contact 1 -> Contact 2 (Company is the root)
- Create an SO with Contact 2 as a customer
- On each of the contacts, click on the SO smart button, all of them have 1 SO shown on the button, but only Constact 1 has none shown once clicked. (Regardless if Contact 1 is an Individual or Company)

Fix:
Simplify domain search to only take into account the children's ids.
There is no need to make a distinction between a contact that is a company or not, since all commercial_partners are also partners by default.

Affected versions:
- 14.0
- 15.0
- saas-15.2
- saas-15.3
- master

opw-2961030

closes odoo/odoo#100377

Signed-off-by: default avatarPiryns Victor (pivi) <pivi@odoo.com>
parent c00fd50e
Branches
Tags
No related merge requests found
......@@ -47,8 +47,5 @@ class ResPartner(models.Model):
def action_view_sale_order(self):
action = self.env['ir.actions.act_window']._for_xml_id('sale.act_res_partner_2_sale_order')
all_child = self.with_context(active_test=False).search([('id', 'child_of', self.ids)])
if self.is_company:
action['domain'] = [('partner_id.commercial_partner_id.id', '=', self.id), ('partner_id', 'in', all_child.ids)]
else:
action['domain'] = [('partner_id.id', '=', self.id), ('partner_id', 'in', all_child.ids)]
action["domain"] = [("partner_id", "in", all_child.ids)]
return action
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment