[IMP] partner_profiles: remove position profiles from child_ids
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "partner_profiles",
|
"name": "partner_profiles",
|
||||||
"version": "12.0.2.3.1",
|
"version": "12.0.2.4.0",
|
||||||
"author": "Elabore",
|
"author": "Elabore",
|
||||||
"website": "https://elabore.coop",
|
"website": "https://elabore.coop",
|
||||||
"maintainer": "Stéphan Sainléger",
|
"maintainer": "Stéphan Sainléger",
|
||||||
|
@@ -100,6 +100,12 @@ msgstr "Société"
|
|||||||
msgid "Contact"
|
msgid "Contact"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: partner_profiles
|
||||||
|
#: model:ir.model.fields,field_description:partner_profiles.field_res_partner__child_ids
|
||||||
|
#: model:ir.model.fields,field_description:partner_profiles.field_res_users__child_ids
|
||||||
|
msgid "Contacts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: partner_profiles
|
#. module: partner_profiles
|
||||||
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
|
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
|
||||||
msgid "Country"
|
msgid "Country"
|
||||||
|
@@ -85,6 +85,12 @@ msgstr ""
|
|||||||
msgid "Contact"
|
msgid "Contact"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: partner_profiles
|
||||||
|
#: model:ir.model.fields,field_description:partner_profiles.field_res_partner__child_ids
|
||||||
|
#: model:ir.model.fields,field_description:partner_profiles.field_res_users__child_ids
|
||||||
|
msgid "Contacts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: partner_profiles
|
#. module: partner_profiles
|
||||||
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
|
#: model_terms:ir.ui.view,arch_db:partner_profiles.partner_profiles_form_view
|
||||||
msgid "Country"
|
msgid "Country"
|
||||||
|
@@ -39,7 +39,9 @@ class res_partner(models.Model):
|
|||||||
other_contact_ids = fields.One2many(
|
other_contact_ids = fields.One2many(
|
||||||
domain=[("is_position_profile", "=", True)]
|
domain=[("is_position_profile", "=", True)]
|
||||||
)
|
)
|
||||||
|
child_ids = fields.One2many(
|
||||||
|
domain=[("is_position_profile", "=", False)]
|
||||||
|
)
|
||||||
structure_position_ids = fields.One2many('res.partner', 'parent_id', string="Structure's positions", domain=[('active', '=', True), ('is_position_profile', '=', True)])
|
structure_position_ids = fields.One2many('res.partner', 'parent_id', string="Structure's positions", domain=[('active', '=', True), ('is_position_profile', '=', True)])
|
||||||
|
|
||||||
@api.depends("partner_profile", "other_contact_ids")
|
@api.depends("partner_profile", "other_contact_ids")
|
||||||
@@ -87,7 +89,7 @@ class res_partner(models.Model):
|
|||||||
def _onchange_is_company(self):
|
def _onchange_is_company(self):
|
||||||
for partner in self:
|
for partner in self:
|
||||||
if partner.is_main_profile:
|
if partner.is_main_profile:
|
||||||
if partner.has_position or partner.child_ids.filtered(lambda c: c.is_position_profile):
|
if partner.has_position or partner.structure_position_ids.filtered(lambda c: c.is_position_profile):
|
||||||
raise UserError("You can not modify the partner company type when the parner has postion profiles associated. Please remove the position profiles before retrying.")
|
raise UserError("You can not modify the partner company type when the parner has postion profiles associated. Please remove the position profiles before retrying.")
|
||||||
if partner.public_profile_id:
|
if partner.public_profile_id:
|
||||||
# public_partner = self.env["res.partner"].browse(partner.public_profile_id)[0]
|
# public_partner = self.env["res.partner"].browse(partner.public_profile_id)[0]
|
||||||
@@ -138,9 +140,8 @@ class res_partner(models.Model):
|
|||||||
for partner in self:
|
for partner in self:
|
||||||
if partner.is_company:
|
if partner.is_company:
|
||||||
# Delete position profiles linked to the company main profile
|
# Delete position profiles linked to the company main profile
|
||||||
child_ids = self.env["res.partner"].search([("parent_id", "=", partner.id), ("is_position_profile", "=", True)])
|
for position in self.structure_position_ids:
|
||||||
for child in child_ids:
|
position.unlink()
|
||||||
child.unlink()
|
|
||||||
return super(res_partner, self).unlink()
|
return super(res_partner, self).unlink()
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
@@ -57,9 +57,9 @@
|
|||||||
expr="//field[@name='child_ids']" position="before">
|
expr="//field[@name='child_ids']" position="before">
|
||||||
<div class="alert alert-info" role="alert" style="margin-bottom:0px;"
|
<div class="alert alert-info" role="alert" style="margin-bottom:0px;"
|
||||||
attrs="{'invisible': [('is_company','=', False)]}">
|
attrs="{'invisible': [('is_company','=', False)]}">
|
||||||
<span>Please find here <strong>all</strong> the profiles/addresses/contacts
|
<span>Please find here <strong>all</strong> the addresses/contacts linked to
|
||||||
linked to this main profile. Contact creation from this tab <strong>only
|
this main profile. Contact creation from this tab <strong>only
|
||||||
generates new main profiles</strong>.</span>
|
generates new main profiles</strong>.</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="alert alert-info" role="alert" style="margin-bottom:0px;"
|
<div class="alert alert-info" role="alert" style="margin-bottom:0px;"
|
||||||
attrs="{'invisible': [('is_company','=', True)]}">
|
attrs="{'invisible': [('is_company','=', True)]}">
|
||||||
|
Reference in New Issue
Block a user