Browse Source

[MIG] partner_contact_in_several_companies: Migration to 13.0

14.0
Fábio Oliveira 4 years ago
committed by Jacob Oldfield
parent
commit
b9a334ee44
  1. 3
      partner_contact_in_several_companies/__init__.py
  2. 11
      partner_contact_in_several_companies/__manifest__.py
  3. 1
      partner_contact_in_several_companies/demo/ir_actions.xml
  4. 1
      partner_contact_in_several_companies/models/ir_actions.py
  5. 6
      partner_contact_in_several_companies/models/res_partner.py
  6. 76
      partner_contact_in_several_companies/views/res_partner.xml

3
partner_contact_in_several_companies/__init__.py

@ -1,3 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# -*- coding: utf-8 -*-
from . import models from . import models

11
partner_contact_in_several_companies/__manifest__.py

@ -1,15 +1,15 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# -*- coding: utf-8 -*-
{ {
"name": "Contacts in several partners", "name": "Contacts in several partners",
"summary": "Allow to have one contact in several partners", "summary": "Allow to have one contact in several partners",
"version": "12.0.2.0.0",
"version": "13.0.1.0.0",
"category": "Customer Relationship Management", "category": "Customer Relationship Management",
"website": "https://github.com/OCA/partner-contact", "website": "https://github.com/OCA/partner-contact",
"author": "Nicolas JEUDY, Odoo Community Association (OCA),Odoo SA",
"author": "Fabio Oliveira, Odoo Community Association (OCA),Odoo SA",
"license": "AGPL-3", "license": "AGPL-3",
"depends": [ "depends": [
"base", "base",
"contacts",
"partner_contact_personal_information_page", "partner_contact_personal_information_page",
], ],
"data": [ "data": [
@ -19,4 +19,7 @@
"demo/res_partner.xml", "demo/res_partner.xml",
"demo/ir_actions.xml", "demo/ir_actions.xml",
], ],
"application": False,
"installable": True,
"auto_install": False,
} }

1
partner_contact_in_several_companies/demo/ir_actions.xml

@ -4,7 +4,6 @@
<field name="name">All Customers in All Positions</field> <field name="name">All Customers in All Positions</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field> <field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field> <field name="view_mode">kanban,tree,form</field>
<field name="context">{"search_default_customer":1, 'search_show_all_positions': {'is_set': True, 'set_value': True}}</field> <field name="context">{"search_default_customer":1, 'search_show_all_positions': {'is_set': True, 'set_value': True}}</field>
<field name="search_view_id" ref="base.view_res_partner_filter"/> <field name="search_view_id" ref="base.view_res_partner_filter"/>

1
partner_contact_in_several_companies/models/ir_actions.py

@ -6,7 +6,6 @@ from odoo import api, models
class IRActionsWindow(models.Model): class IRActionsWindow(models.Model):
_inherit = 'ir.actions.act_window' _inherit = 'ir.actions.act_window'
@api.multi
def read(self, fields=None, context=None, load='_classic_read'): def read(self, fields=None, context=None, load='_classic_read'):
actions = super(IRActionsWindow, self).read(fields=fields, load=load) actions = super(IRActionsWindow, self).read(fields=fields, load=load)
for action in actions: for action in actions:

6
partner_contact_in_several_companies/models/res_partner.py

@ -27,7 +27,6 @@ class ResPartner(models.Model):
string='Others Positions', string='Others Positions',
) )
@api.multi
@api.depends('contact_id') @api.depends('contact_id')
def _compute_contact_type(self): def _compute_contact_type(self):
for rec in self: for rec in self:
@ -81,22 +80,18 @@ class ResPartner(models.Model):
vals['name'] = modified_self.browse(vals['contact_id']).name vals['name'] = modified_self.browse(vals['contact_id']).name
return super(ResPartner, modified_self).create(vals) return super(ResPartner, modified_self).create(vals)
@api.multi
def read(self, fields=None, load='_classic_read'): def read(self, fields=None, load='_classic_read'):
modified_self = self._basecontact_check_context('read') modified_self = self._basecontact_check_context('read')
return super(ResPartner, modified_self).read(fields=fields, load=load) return super(ResPartner, modified_self).read(fields=fields, load=load)
@api.multi
def write(self, vals): def write(self, vals):
modified_self = self._basecontact_check_context('write') modified_self = self._basecontact_check_context('write')
return super(ResPartner, modified_self).write(vals) return super(ResPartner, modified_self).write(vals)
@api.multi
def unlink(self): def unlink(self):
modified_self = self._basecontact_check_context('unlink') modified_self = self._basecontact_check_context('unlink')
return super(ResPartner, modified_self).unlink() return super(ResPartner, modified_self).unlink()
@api.multi
def _compute_commercial_partner(self): def _compute_commercial_partner(self):
""" Returns the partner that is considered the commercial """ Returns the partner that is considered the commercial
entity of this partner. The commercial entity holds the master data entity of this partner. The commercial entity holds the master data
@ -132,7 +127,6 @@ class ResPartner(models.Model):
if contact_vals: if contact_vals:
self.with_context(__update_contact_lock=True).write(contact_vals) self.with_context(__update_contact_lock=True).write(contact_vals)
@api.multi
def _fields_sync(self, update_values): def _fields_sync(self, update_values):
"""Sync commercial fields and address fields from company and to """Sync commercial fields and address fields from company and to
children, contact fields from contact and to attached contact children, contact fields from contact and to attached contact

76
partner_contact_in_several_companies/views/res_partner.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<record id="view_res_partner_filter_contact" model="ir.ui.view">
<record id="view_res_partner_filter_contact" model="ir.ui.view">
<field name="name">res.partner.select.contact</field> <field name="name">res.partner.select.contact</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/> <field name="inherit_id" ref="base.view_res_partner_filter"/>
@ -15,9 +15,9 @@
<filter string="Person" name="group_person" context="{'group_by': 'contact_id'}"/> <filter string="Person" name="group_person" context="{'group_by': 'contact_id'}"/>
</xpath> </xpath>
</field> </field>
</record>
</record>
<record id="view_res_partner_tree_contact" model="ir.ui.view">
<record id="view_res_partner_tree_contact" model="ir.ui.view">
<field name="name">res.partner.tree.contact</field> <field name="name">res.partner.tree.contact</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/> <field name="inherit_id" ref="base.view_partner_tree"/>
@ -26,9 +26,9 @@
<field name="contact_id" invisible="1"/> <field name="contact_id" invisible="1"/>
</field> </field>
</field> </field>
</record>
</record>
<record model="ir.ui.view" id="view_partner_form_inherit">
<record model="ir.ui.view" id="view_partner_form_inherit">
<field name="name">res.partner.form.contact</field> <field name="name">res.partner.form.contact</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/> <field name="inherit_id" ref="base.view_partner_form"/>
@ -49,8 +49,11 @@
<field name="contact_type" invisible="1"/> <field name="contact_type" invisible="1"/>
</field> </field>
<page name='internal_notes' position="before"> <page name='internal_notes' position="before">
<page name="other_position" string="Other Positions" attrs="{'invisible': ['|',('is_company','=',True),('contact_id','!=',False)]}">
<field name="other_contact_ids" context="{'default_contact_id': active_id, 'default_name': name, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier}" mode="kanban">
<page name="other_position" string="Other Positions"
attrs="{'invisible': ['|',('is_company','=',True),('contact_id','!=',False)]}">
<field name="other_contact_ids"
context="{'default_contact_id': active_id, 'default_name': name, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id}"
mode="kanban">
<kanban create="false"> <kanban create="false">
<field name="color"/> <field name="color"/>
<field name="name"/> <field name="name"/>
@ -67,7 +70,7 @@
<field name="country_id"/> <field name="country_id"/>
<field name="mobile"/> <field name="mobile"/>
<field name="state_id"/> <field name="state_id"/>
<field name="image"/>
<field name="image_128"/>
<field name="lang"/> <field name="lang"/>
<templates> <templates>
<t t-name="kanban-box"> <t t-name="kanban-box">
@ -75,18 +78,28 @@
<div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '') + ' oe_kanban_global_click'"> <div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '') + ' oe_kanban_global_click'">
<a t-if="!read_only_mode" type="delete" class="fa fa-times pull-right"/> <a t-if="!read_only_mode" type="delete" class="fa fa-times pull-right"/>
<div class="o_kanban_image"> <div class="o_kanban_image">
<img t-if="record.image.raw_value" t-att-src="'data:image/png;base64,'+record.image.raw_value"/>
<t t-if="!record.image.raw_value">
<img t-if="record.is_company.raw_value === true" t-att-src='_s + "/base/static/src/img/company_image.png"'/>
<img t-if="record.is_company.raw_value === false" t-att-src='_s + "/base/static/src/img/avatar.png"'/>
<img t-if="record.image_128.raw_value" t-att-src="'data:image/png;base64,' + record.image_128.raw_value"/>
<t t-if="!record.image_128.raw_value">
<img alt="Logo" t-if="record.is_company.raw_value === true" t-att-src='_s + "/base/static/src/img/company_image.png"'/>
<img alt="Avatar" t-if="record.is_company.raw_value === false" t-att-src='_s + "/base/static/src/img/avatar_grey.png"'/>
</t> </t>
</div> </div>
<div class="oe_kanban_details"> <div class="oe_kanban_details">
<field name="name"/> <field name="name"/>
<div t-if="record.function.raw_value"><field name="function"/> at <field name="parent_id"/></div>
<div t-if="record.email.raw_value"><field name="email"/></div>
<div t-if="record.phone.raw_value">Phone: <field name="phone"/></div>
<div t-if="record.mobile.raw_value">Mobile: <field name="mobile"/></div>
<div t-if="record.function.raw_value">
<field name="function"/>
at
<field name="parent_id"/>
</div>
<div t-if="record.email.raw_value">
<field name="email"/>
</div>
<div t-if="record.phone.raw_value">Phone:
<field name="phone"/>
</div>
<div t-if="record.mobile.raw_value">Mobile:
<field name="mobile"/>
</div>
</div> </div>
</div> </div>
</t> </t>
@ -102,16 +115,21 @@
<div> <div>
<div class="o_address_format" name="div_address"> <div class="o_address_format" name="div_address">
<field name="street" placeholder="Street..." class="o_address_street"/> <field name="street" placeholder="Street..." class="o_address_street"/>
<field name="street2" placeholder="Street 2..." class="o_address_street"/>
<field name="street2" placeholder="Street 2..."
class="o_address_street"/>
<field name="city" placeholder="City" class="o_address_city"/> <field name="city" placeholder="City" class="o_address_city"/>
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}' context="{'country_id': country_id, 'zip': zip}"/>
<field name="state_id" class="o_address_state" placeholder="State"
options='{"no_open": True}'
context="{'country_id': country_id, 'zip': zip}"/>
<field name="zip" placeholder="ZIP" class="o_address_zip"/> <field name="zip" placeholder="ZIP" class="o_address_zip"/>
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
<field name="country_id" placeholder="Country" class="o_address_country"
options='{"no_open": True, "no_create": True}'/>
</div> </div>
</div> </div>
</group> </group>
<group> <group>
<field name="name" string="Contact Name" attrs="{'required' : [('type', '=', 'contact')]}"/>
<field name="name" string="Contact Name"
attrs="{'required' : [('type', '=', 'contact')]}"/>
<field name="title" placeholder="e.g. Mr." <field name="title" placeholder="e.g. Mr."
attrs="{'invisible': [('type','&lt;&gt;', 'contact')]}"/> attrs="{'invisible': [('type','&lt;&gt;', 'contact')]}"/>
<field name="function" placeholder="e.g. Sales Director" <field name="function" placeholder="e.g. Sales Director"
@ -122,8 +140,6 @@
<field name="comment" placeholder="internal note..."/> <field name="comment" placeholder="internal note..."/>
</group> </group>
</group> </group>
<field name="supplier" invisible="True"/>
<field name="customer" invisible="True"/>
<field name="lang" invisible="True"/> <field name="lang" invisible="True"/>
</sheet> </sheet>
</form> </form>
@ -131,9 +147,9 @@
</page> </page>
</page> </page>
</field> </field>
</record>
</record>
<record id="personal_contact_information" model="ir.ui.view">
<record id="personal_contact_information" model="ir.ui.view">
<field name="name">Contacts in several partners: personal info</field> <field name="name">Contacts in several partners: personal info</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="partner_contact_personal_information_page.personal_information"/> <field name="inherit_id" ref="partner_contact_personal_information_page.personal_information"/>
@ -154,9 +170,9 @@
</p> </p>
</xpath> </xpath>
</field> </field>
</record>
</record>
<record model="ir.ui.view" id="view_res_partner_kanban_contact">
<record model="ir.ui.view" id="view_res_partner_kanban_contact">
<field name="name">res.partner.kanban.contact</field> <field name="name">res.partner.kanban.contact</field>
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/> <field name="inherit_id" ref="base.res_partner_kanban_view"/>
@ -171,11 +187,13 @@
</field> </field>
<xpath expr="//t[@t-name='kanban-box']//div[hasclass('oe_kanban_details')]/ul/li[3]" position="after"> <xpath expr="//t[@t-name='kanban-box']//div[hasclass('oe_kanban_details')]/ul/li[3]" position="after">
<t t-if="record.other_contact_ids.raw_value.length &gt; 0"> <t t-if="record.other_contact_ids.raw_value.length &gt; 0">
<li>+<t t-esc="record.other_contact_ids.raw_value.length"/>
<li>+
<t t-esc="record.other_contact_ids.raw_value.length"/>
<t t-if="record.other_contact_ids.raw_value.length == 1">other position</t> <t t-if="record.other_contact_ids.raw_value.length == 1">other position</t>
<t t-if="record.other_contact_ids.raw_value.length &gt; 1">other positions</t></li>
<t t-if="record.other_contact_ids.raw_value.length &gt; 1">other positions</t>
</li>
</t> </t>
</xpath> </xpath>
</field> </field>
</record>
</record>
</odoo> </odoo>
Loading…
Cancel
Save