add view to import relation

This commit is contained in:
Benoît Vézina 2023-10-29 14:10:37 -04:00
parent 21008aad57
commit f0dea08da2
4 changed files with 230 additions and 31 deletions

View file

@ -23,7 +23,9 @@
'data/partner_tags_data.xml',
'data/partner_relations_data.xml',
'views/res_partner_views.xml',
'views/res_partner_relation_views.xml'
'views/res_partner_relation_views.xml',
'views/membership_membership_line.xml'
],
'demo': [
# Reference to demo data files

View file

@ -7,13 +7,29 @@ from odoo.addons.website.models import ir_http
class ResPartner(models.Model):
_inherit = 'res.partner'
surface = fields.Float(string='Surface (ha)')
lot_number = fields.Text(string='Lot Number')
ref_project = fields.Text(string='Project No')
intent_signing = fields.Boolean(string='Intent to sign')
cyberimpact = fields.Boolean(string='Cyberimpact')
specification_date = fields.Date(string='Specification date')
crm_stage_activity = fields.Text(string='Activity Stage')
surface = fields.Float(string='Surface (ha)') # terrain
lot_number = fields.Text(string='Lot Number') # terrain
ref_project = fields.Text(string='Project No') # proprio
intent_signing = fields.Boolean(string='Intent to sign') # proprio
cyberimpact = fields.Boolean(string='Cyberimpact') # proprio
specification_date = fields.Date(string='Specification date') # proprio
crm_stage_activity = fields.Text(string='Activity Stage') # proprio
property_count = fields.Integer(string='Property count', compute='_compute_property_count')
is_owner = fields.Boolean(string='Is Owner', compute='_compute_property_count')
sethy_firs_tdate = fields.Date(string='First membership date') # member
sethy_last_date = fields.Date(string='Last membership date') # member
sethy_renew_date = fields.Date(string='Next renew date date') # member
sethy_certification_date = fields.Date(string='Certification date date') # member
sethy_payment_type = fields.Text(string='Payment Type') # member
sethy_amount = fields.Float(string='Payment amount') # Member
is_property = fields.Boolean(
string='Is Property',
default=False
) # True if property, False if not
interest_level = fields.Selection(
selection=[
@ -21,9 +37,9 @@ class ResPartner(models.Model):
('2', 'Low'),
('3', 'Average'),
('4', 'High')],
string='Interest Level')
string='Interest Level') # proprio
company_use = fields.Text(string='Company related')
company_use = fields.Text(string='Company related') # proprio
relation_owner_ids = fields.One2many(
"res.partner.relation.all",
@ -42,7 +58,7 @@ class ResPartner(models.Model):
for record in self:
record.relation_owner_ids = record.relation_all_ids.filtered(
lambda line: (
line.type_id.name == 'Owner' and not line.is_inverse)
line.type_id.name == 'Owner' and not line.is_inverse)
)
@api.depends('relation_all_ids')
@ -52,3 +68,33 @@ class ResPartner(models.Model):
lambda line: (
line.type_id.name == 'Owner' and line.is_inverse)
)
# @api.depends('is_property')
# def _forcing_company(self):
# for record in self:
# if record.is_property:
# record.is_company = True
@api.onchange('is_property')
def _onchange_is_property(self):
""" Set is_company to True when is_property is set to True. """
if self.is_property:
self.is_company = True
@api.onchange('is_company')
def _onchange_is_company(self):
""" Set is_property to False when is_company is set to False. """
if not self.is_company:
self.is_property = False
@api.onchange('lot_number')
def _onchange_lot_number(self):
for lot in self:
if lot.lot_number:
lot.name = "Lot " + str(lot.lot_number)
@api.depends('relation_property_ids')
def _compute_property_count(self):
for record in self:
record.property_count = len(record.relation_property_ids)
record.is_owner = record.property_count > 0

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="tree_res_partner_relation" model="ir.ui.view">
<field name="model">membership.membership_line</field>
<field name="arch" type="xml">
<tree editable="top">
<field
name="partner"
required="True"
/>
<field
name="date"
/>
<field
name="date_from"
/>
<field name="date_to" />
<field name="membership_id" />
</tree>
</field>
</record>
<!-- <record id="search_res_partner_relation_all" model="ir.ui.view">-->
<!-- <field name="model">res.partner.relation.all</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <search string="Search Relations">-->
<!-- <field name="any_partner_id" widget="many2one" />-->
<!-- <field name="this_partner_id" />-->
<!-- <field name="other_partner_id" />-->
<!-- <field name="type_selection_id" />-->
<!-- <filter-->
<!-- name="left_to_right"-->
<!-- string="Left to right"-->
<!-- domain="[('is_inverse', '=', False)]"-->
<!-- />-->
<!-- <filter-->
<!-- name="right_to_left"-->
<!-- string="Right to left"-->
<!-- domain="[('is_inverse', '=', True)]"-->
<!-- />-->
<!-- <filter-->
<!-- name="include_part_records"-->
<!-- string="Include past records"-->
<!-- context="{'active_test': False}"-->
<!-- />-->
<!-- <group expand="0" string="Group By">-->
<!-- <filter-->
<!-- name="group_by_this_partner_id"-->
<!-- string="One Partner"-->
<!-- context="{'group_by': 'this_partner_id'}"-->
<!-- />-->
<!-- <filter-->
<!-- name="group_by_type_selection_id"-->
<!-- string="Relationship Type"-->
<!-- context="{'group_by': 'type_selection_id'}"-->
<!-- />-->
<!-- <filter-->
<!-- name="group_by_other_partner_id"-->
<!-- string="Other Partner"-->
<!-- context="{'group_by': 'other_partner_id'}"-->
<!-- />-->
<!-- </group>-->
<!-- </search>-->
<!-- </field>-->
<!-- </record>-->
<record id="action_membership_membership_line" model="ir.actions.act_window">
<field name="name">Membership line</field>
<field name="res_model">membership.membership_line</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="tree_res_partner_relation" />
<!-- <field name="search_view_id" ref="search_res_partner_relation_all" />-->
<!-- <field name="context">{'active_test': 0}</field>-->
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Record and track your partners'membership
</p>
</field>
</record>
<menuitem
id="menu_membership_membership_line"
sequence="3"
parent="membership.menu_association"
action="action_membership_membership_line"
/>
</odoo>

View file

@ -6,38 +6,93 @@
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="company_type" position="after">
<label for="is_property" string="Property"/>
<field name="is_property"/>
</field>
<xpath expr="//field[@name='name' and @id='company']" position="replace">
<field id="company" class="text-break" name="name" default_focus="1"
placeholder="e.g. Lumber Inc"
attrs="{'required' : [('type', '=', 'contact')], 'invisible': ['|', ('is_company','=', False),
('is_property','=', True)]}"/>
<field id="lot_number" class="text-break" name="lot_number" placeholder="123456789"
attrs="{'invisible': [('is_property','=', False)]}"/>
</xpath>
<button name="schedule_meeting" position="attributes">
<attribute name="attrs">{'invisible': [('is_property', '=', True)]}</attribute>
</button>
<button name="action_view_opportunity" position="attributes">
<attribute name="attrs">{'invisible': [('is_property', '=', True)]}</attribute>
</button>
<button name="action_view_partner_invoices" position="attributes">
<attribute name="attrs">{'invisible': [('is_property', '=', True)]}</attribute>
</button>
<button name="%(payment.action_payment_token)d" position="attributes">
<attribute name="attrs">{'invisible': ['|', ('payment_token_count', '=', 0), ('is_property', '=', True)]}</attribute>
</button>
<xpath expr="//page[@name='contact_addresses']" position="attributes">
<attribute name="attrs">{'invisible': [('is_property','=', True)]}</attribute>
</xpath>
<xpath expr="//page[@name='sales_purchases']" position="attributes">
<attribute name="attrs">{'invisible': [('is_property','=', True)]}</attribute>
</xpath>
<xpath expr="//page[@name='membership']" position="attributes">
<attribute name="attrs">{'invisible': [('is_property','=', True)]}</attribute>
</xpath>
<xpath expr="//page[@name='accounting']" position="attributes">
<attribute name="attrs">{'invisible': [('is_property','=', True)]}</attribute>
</xpath>
<xpath expr="//field[@name='function']/ancestor::group[1]" position="attributes">
<attribute name="attrs">{'invisible': [('is_property','=', True)]}</attribute>
</xpath>
<xpath expr="//field[@name='function']/ancestor::group[1]" position="after">
<group attrs="{'invisible': [('is_property','=', False)]}">
<field name="surface"/>
<field name="category_id" widget="many2many_tags"
options="{'color_field': 'color', 'no_create_edit': True}"
placeholder="e.g. &quot;B2B&quot;, &quot;VIP&quot;, &quot;Consulting&quot;, ..."/>
</group>
</xpath>
<xpath expr="//page[@name='contact_addresses']" position="after">
<page string="Property" name="bemade_sethy_configuration.res_partner.defaults.form">
<group string="All relations">
<field name="relation_all_ids">
<tree editable="top" string="">
<field name="this_partner_id" required="True" options="{'no_create': True}" attrs="{}" invisible="1"/>
<field name="type_selection_id" required="True" options="{'no_create': True}"/>
<field name="other_partner_id" required="True" options="{'no_create': True}"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="active" invisible="1"/>
</tree>
</field>
</group>
<group string="All Owners">
<group string="All Owners" attrs="{'invisible': [['is_property','=',False]]}">
<field name="relation_property_ids" string="">
<tree editable="top">
<field name="this_partner_id" required="True" options="{'no_create': True}" attrs="{}" invisible="1"/>
<field name="type_selection_id" required="True" options="{'no_create': True}" invisible="1"/>
<field name="other_partner_id" required="True" options="{'no_create': True}" string="Owner"/>
<field name="this_partner_id" required="True" options="{'no_create': True}"
attrs="{}" invisible="1"/>
<field name="type_selection_id" required="True" options="{'no_create': True}"
invisible="1"/>
<field name="other_partner_id" required="True" options="{'no_create': True}"
string="Owner"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="active" invisible="1"/>
</tree>
</field>
</group>
<group string="All Properties">
<group string="All Properties" attrs="{'invisible': [['is_property','=',True]]}">
<field name="relation_owner_ids" string="">
<tree editable="top">
<field name="this_partner_id" required="True" options="{'no_create': True}" attrs="{}" invisible="1"/>
<field name="type_selection_id" required="True" options="{'no_create': True}" invisible="1"/>
<field name="other_partner_id" required="True" options="{'no_create': True}" string="Property"/>
<field name="this_partner_id" required="True"
options="{'no_create': True}"
attrs="{}" invisible="1"
/>
<field name="type_selection_id" required="True" options="{'no_create': True}"
invisible="1"/>
<field name="other_partner_id" required="True" options="{'no_create': True}"
string="Property"/>
<field name="date_start"/>
<field name="date_end"/>
<field name="active" invisible="1"/>
@ -46,6 +101,17 @@
</group>
</page>
</xpath>
<xpath expr="//page[@name='contact_addresses']" position="after">
<page string="Sethy" name="bemade_sethy_configuration.res_partner.page.sethy">
<group>
<field name="ref_project"/>
<field name="intent_signing"/>
<field name="cyberimpact"/>
<field name="specification_date"/>
<field name="crm_stage_activity"/>
</group>
</page>
</xpath>
</field>
</record>