bemade_fsm: Updated to require bemade_partner_root_ancestor, refactored out call to Partner.get_root_ancestor().

This commit is contained in:
Marc Durepos 2023-06-19 11:52:13 -04:00
parent 38a6d492b4
commit 1635abb3c8
4 changed files with 2 additions and 12 deletions

View file

@ -34,6 +34,7 @@
'sale_stock',
'industry_fsm',
'industry_fsm_sale',
'bemade_partner_root_ancestor',
],
'data': ['views/task_template_views.xml',
'views/equipment.xml',

View file

@ -56,7 +56,7 @@ class Equipment(models.Model):
@api.depends('partner_location_id')
def _compute_partner(self):
for rec in self:
rec.partner_id = rec.partner_location_id and rec.partner_location_id.get_root_ancestor()
rec.partner_id = rec.partner_location_id and rec.partner_location_id.root_ancestor
@api.depends('pid_tag', 'name')
def _compute_complete_name(self):

View file

@ -43,13 +43,3 @@ class Partner(models.Model):
for rec in self:
all_equipmemt_ids = self.env['bemade_fsm.equipment'].search([('partner_id', '=', rec.id)])
rec.equipment_count = len(all_equipmemt_ids)
def get_root_ancestor(self):
""" Returns the partner at the top of the parent-child hierarchy. """
self.ensure_one()
return self.parent_id and self.parent_id.get_root_ancestor() or self
def get_first_company_ancestor(self):
""" Returns the first ancestor that is a company """
self.ensure_one()
return self.is_company and self or self.parent_id and self.parent_id.get_first_company_ancestor()

View file

@ -1,6 +1,5 @@
from .test_bemade_fsm_common import FSMManagerUserTransactionCase
from odoo.tests.common import HttpCase, tagged
from odoo.tools import mute_logger
from odoo.exceptions import MissingError
from odoo import Command
from psycopg2.errors import ForeignKeyViolation