Browse Source

[MIG] partner_contact_in_several_companies: Migration to 12.0

12.0
kongrattapong 5 years ago
parent
commit
cf2ad0a751
  1. 1
      partner_contact_in_several_companies/README.rst
  2. 2
      partner_contact_in_several_companies/__init__.py
  3. 7
      partner_contact_in_several_companies/__manifest__.py
  4. 3
      partner_contact_in_several_companies/models/__init__.py
  5. 3
      partner_contact_in_several_companies/models/ir_actions.py
  6. 29
      partner_contact_in_several_companies/models/res_partner.py
  7. 3
      partner_contact_in_several_companies/tests/__init__.py
  8. 3
      partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py
  9. 2
      partner_contact_in_several_companies/views/res_partner.xml

1
partner_contact_in_several_companies/README.rst

@ -74,6 +74,7 @@ Contributors
* Richard deMeester <richard@willowit.com.au> * Richard deMeester <richard@willowit.com.au>
* Nicolas JEUDY <https://github.com/njeudy> * Nicolas JEUDY <https://github.com/njeudy>
* Franco Tampieri <franco@tampieri.info> * Franco Tampieri <franco@tampieri.info>
* Rattapong Chokmasermkul <rattapongc@ecosoft.co.th>
Maintainer Maintainer
---------- ----------

2
partner_contact_in_several_companies/__init__.py

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

7
partner_contact_in_several_companies/__manifest__.py

@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"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": "11.0.1.0.1",
"version": "12.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": "Nicolas JEUDY, Odoo Community Association (OCA),Odoo SA",
"license": "AGPL-3", "license": "AGPL-3",
"depends": [ "depends": [
"base", "base",

3
partner_contact_in_several_companies/models/__init__.py

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

3
partner_contact_in_several_companies/models/ir_actions.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models from odoo import api, models
@ -13,7 +12,7 @@ class IRActionsWindow(models.Model):
for action in actions: for action in actions:
if action.get('res_model', '') == 'res.partner': if action.get('res_model', '') == 'res.partner':
# By default, only show standalone contact # By default, only show standalone contact
action_context = action.get('context', '{}') or '{}'
action_context = action.get('context', '{}')
if 'search_show_all_positions' not in action_context: if 'search_show_all_positions' not in action_context:
action['context'] = action_context.replace( action['context'] = action_context.replace(
'{', '{',

29
partner_contact_in_several_companies/models/res_partner.py

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models, _
from odoo import api, fields, models
from odoo.osv import expression from odoo.osv import expression
@ -9,20 +8,24 @@ class ResPartner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
contact_type = fields.Selection( contact_type = fields.Selection(
[('standalone', _('Standalone Contact')),
('attached', _('Attached to existing Contact')),
[('standalone', 'Standalone Contact'),
('attached', 'Attached to existing Contact'),
], ],
compute='_compute_contact_type', compute='_compute_contact_type',
store=True, store=True,
index=True, index=True,
default='standalone') default='standalone')
contact_id = fields.Many2one('res.partner', string='Main Contact',
domain=[('is_company', '=', False),
('contact_type', '=', 'standalone'),
],
)
other_contact_ids = fields.One2many('res.partner', 'contact_id',
string='Others Positions')
contact_id = fields.Many2one(
'res.partner',
string='Main Contact',
domain=[('is_company', '=', False),
('contact_type', '=', 'standalone'),
],
)
other_contact_ids = fields.One2many(
'res.partner', 'contact_id',
string='Others Positions',
)
@api.multi @api.multi
@api.depends('contact_id') @api.depends('contact_id')
@ -59,8 +62,8 @@ class ResPartner(models.Model):
) )
attached_contacts = super(ResPartner, self).search( attached_contacts = super(ResPartner, self).search(
attached_contact_args) attached_contact_args)
args = expression.OR((
expression.AND(([('contact_type', '=', 'standalone')], args)),
args = expression.OR((expression.AND((
[('contact_type', '=', 'standalone')], args)),
[('other_contact_ids', 'in', attached_contacts.ids)], [('other_contact_ids', 'in', attached_contacts.ids)],
)) ))
return super(ResPartner, self).search(args, offset=offset, return super(ResPartner, self).search(args, offset=offset,

3
partner_contact_in_several_companies/tests/__init__.py

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

3
partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests import common from odoo.tests import common

2
partner_contact_in_several_companies/views/res_partner.xml

@ -49,7 +49,7 @@
<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 string="Other Positions" attrs="{'invisible': ['|',('is_company','=',True),('contact_id','!=',False)]}">
<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"> <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">
<kanban create="false"> <kanban create="false">
<field name="color"/> <field name="color"/>

Loading…
Cancel
Save