[IMP]partner_profiles:add quick filters for admin, public and fonction profiles

This commit is contained in:
2024-11-20 16:55:09 +01:00
parent d43983212c
commit e9c4b7cfc5
3 changed files with 90 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
{ {
"name": "partner_profiles", "name": "partner_profiles",
"version": "16.0.1.0.1", "version": "16.0.1.0.2",
"author": "Elabore", "author": "Elabore",
"website": "https://elabore.coop", "website": "https://elabore.coop",
"maintainer": "Stéphan Sainléger", "maintainer": "Stéphan Sainléger",

View File

@@ -287,11 +287,12 @@ class res_partner(models.Model):
is_company=False, is_company=False,
active=True, active=True,
with_parent=False, with_parent=False,
partner_profile=False
): ):
search_values = [ search_values = [
("is_company", "=", is_company), ("is_company", "=", is_company),
("active", "=", active), ("active", "=", active),
("partner_profile", "=", False), ("partner_profile", "=", partner_profile),
("type", "=", "contact") ("type", "=", "contact")
] ]
if id: if id:
@@ -438,3 +439,61 @@ class res_partner(models.Model):
) )
count += 1 count += 1
_logger.debug("Last clean") _logger.debug("Last clean")
@api.model
def _migration_main_profile_with_parent_and_not_existing_position_profile(
self, limit=None, id=False
):
partner_profile_main = self.env.ref("partner_profiles.partner_profile_main").id
partner_profile_position = self.env.ref("partner_profiles.partner_profile_position").id
# Main Profil migration with parent_id
search_values = self._get_concerned_partners_search_values(
id,
with_parent=True,
partner_profile=partner_profile_main,
)
partners = self.env["res.partner"].search(search_values, limit=limit)
_logger.debug("Main profile with parent_id - migration count: %s" % len(partners))
count = 0
for partner in partners:
_logger.debug("count: [%s] : %s" % (count, partner.name))
existing_position_partner = self.env["res.partner"].search(
self._get_position_partner_search_values(partner),
limit=1,
)
if not existing_position_partner:
_logger.debug("CREATE Position %s" % partner.name)
self.env["res.partner"].create(
{
"name": partner.name,
"contact_id": partner.id,
"partner_profile": partner_profile_position,
"parent_id": partner.parent_id.id,
"is_position_profile": True,
}
)
_logger.debug("UPDATE Main %s" % partner.name)
# partner.write(
# {
# "parent_id": False,
# }
#)
count += 1
_logger.debug("### End migration ###")
def _get_position_partner_search_values(self, partner):
return [
("active", "=", True),
("type", "=", "contact"),
("is_position_profile", "=", True),
("is_company", "=", False),
("contact_id", "=", partner.id),
"|",
("name", "=", partner.name),
"&",
("email", "!=", False),
("email", "=", partner.email),
]

View File

@@ -1,6 +1,34 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<odoo> <odoo>
<data> <data>
<record id="view_res_partner_filter_profiles" model="ir.ui.view">
<field name="name">res.partner.select.contact</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter" />
<field name="arch" type="xml">
<filter name="type_otherpositions" position="after">
<separator />
<filter
string="Fiches administratives"
name="type_otherpositions"
context="{'search_show_all_positions': {'is_set': True, 'set_value': True}}"
domain="[('is_main_profile', '=', True)]"
/>
<filter
string="Fiches publiques"
name="type_otherpositions"
context="{'search_show_all_positions': {'is_set': True, 'set_value': True}}"
domain="[('is_public_profile', '=', True)]"
/>
<filter
string="Fiches fonctions"
name="type_otherpositions"
context="{'search_show_all_positions': {'is_set': True, 'set_value': True}}"
domain="[('is_position_profile', '=', True)]"
/>
</filter>
</field>
</record>
<record id="partner_profiles_form_view" model="ir.ui.view"> <record id="partner_profiles_form_view" model="ir.ui.view">
<field name="name">Partner Profiles Form View</field> <field name="name">Partner Profiles Form View</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>