From 6d63bdc06325556079dd8361b4e90f4c5feb52e5 Mon Sep 17 00:00:00 2001 From: Timon Tschanz Date: Tue, 26 Mar 2019 17:36:29 +0100 Subject: [PATCH] [12.0][Add] partner_company_group --- partner_company_group/README.rst | 0 partner_company_group/__init__.py | 1 + partner_company_group/__manifest__.py | 24 +++++++++++++++++ partner_company_group/models/__init__.py | 4 +++ .../models/account_invoice.py | 13 +++++++++ partner_company_group/models/crm_lead.py | 13 +++++++++ partner_company_group/models/res_partner.py | 17 ++++++++++++ partner_company_group/models/sale_order.py | 13 +++++++++ partner_company_group/readme/CONTRIBUTORS.rst | 1 + partner_company_group/readme/DESCRIPTION.rst | 1 + .../views/account_invoice_view.xml | 17 ++++++++++++ partner_company_group/views/contact_view.xml | 27 +++++++++++++++++++ .../views/opportunity_view.xml | 16 +++++++++++ .../views/sale_order_view.xml | 16 +++++++++++ 14 files changed, 163 insertions(+) create mode 100644 partner_company_group/README.rst create mode 100644 partner_company_group/__init__.py create mode 100644 partner_company_group/__manifest__.py create mode 100644 partner_company_group/models/__init__.py create mode 100644 partner_company_group/models/account_invoice.py create mode 100644 partner_company_group/models/crm_lead.py create mode 100644 partner_company_group/models/res_partner.py create mode 100644 partner_company_group/models/sale_order.py create mode 100644 partner_company_group/readme/CONTRIBUTORS.rst create mode 100644 partner_company_group/readme/DESCRIPTION.rst create mode 100644 partner_company_group/views/account_invoice_view.xml create mode 100644 partner_company_group/views/contact_view.xml create mode 100644 partner_company_group/views/opportunity_view.xml create mode 100644 partner_company_group/views/sale_order_view.xml diff --git a/partner_company_group/README.rst b/partner_company_group/README.rst new file mode 100644 index 000000000..e69de29bb diff --git a/partner_company_group/__init__.py b/partner_company_group/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/partner_company_group/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_company_group/__manifest__.py b/partner_company_group/__manifest__.py new file mode 100644 index 000000000..bf724a737 --- /dev/null +++ b/partner_company_group/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'Partner Company Group', + 'summary': 'Adds the possibility to add a company group to a company', + 'version': '12.0.1.0.0', + 'category': 'Sales', + 'author': 'Camptocamp SA, Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'depends': [ + 'base', + 'account', + 'crm', + 'sale', + ], + 'website': 'https://github.com/OCA/partner-contact', + 'data': [ + 'views/opportunity_view.xml', + 'views/contact_view.xml', + 'views/sale_order_view.xml', + 'views/account_invoice_view.xml', + ], + 'installable': True, +} diff --git a/partner_company_group/models/__init__.py b/partner_company_group/models/__init__.py new file mode 100644 index 000000000..38824fdaa --- /dev/null +++ b/partner_company_group/models/__init__.py @@ -0,0 +1,4 @@ +from . import res_partner +from . import crm_lead +from . import sale_order +from . import account_invoice diff --git a/partner_company_group/models/account_invoice.py b/partner_company_group/models/account_invoice.py new file mode 100644 index 000000000..1c17a8b81 --- /dev/null +++ b/partner_company_group/models/account_invoice.py @@ -0,0 +1,13 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields + + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + company_group_id = fields.Many2one( + related='partner_id.company_group_id', + store=True + ) diff --git a/partner_company_group/models/crm_lead.py b/partner_company_group/models/crm_lead.py new file mode 100644 index 000000000..8e62b5277 --- /dev/null +++ b/partner_company_group/models/crm_lead.py @@ -0,0 +1,13 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields + + +class CrmLead(models.Model): + _inherit = 'crm.lead' + + company_group_id = fields.Many2one( + related='partner_id.company_group_id', + store=True + ) diff --git a/partner_company_group/models/res_partner.py b/partner_company_group/models/res_partner.py new file mode 100644 index 000000000..6b9b75eb1 --- /dev/null +++ b/partner_company_group/models/res_partner.py @@ -0,0 +1,17 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields + + +class Contact(models.Model): + _inherit = 'res.partner' + + company_group_id = fields.Many2one( + 'res.partner', + 'Company group', + domain=[('is_company', '=', True)] + ) + + def _commercial_fields(self): + return super(Contact, self)._commercial_fields() + ['company_group_id'] diff --git a/partner_company_group/models/sale_order.py b/partner_company_group/models/sale_order.py new file mode 100644 index 000000000..8549b4cdc --- /dev/null +++ b/partner_company_group/models/sale_order.py @@ -0,0 +1,13 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + company_group_id = fields.Many2one( + related='partner_id.company_group_id', + store=True + ) diff --git a/partner_company_group/readme/CONTRIBUTORS.rst b/partner_company_group/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..5a2b30292 --- /dev/null +++ b/partner_company_group/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +Timon Tschanz diff --git a/partner_company_group/readme/DESCRIPTION.rst b/partner_company_group/readme/DESCRIPTION.rst new file mode 100644 index 000000000..a9fce434c --- /dev/null +++ b/partner_company_group/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This Module adds a company group field to companies, which is also propagated to contacts and allows to search and group for the company group in contact, leads, sale orders and invoices. diff --git a/partner_company_group/views/account_invoice_view.xml b/partner_company_group/views/account_invoice_view.xml new file mode 100644 index 000000000..368cb7d1c --- /dev/null +++ b/partner_company_group/views/account_invoice_view.xml @@ -0,0 +1,17 @@ + + + + account.invoice.select + account.invoice + 2 + + + + + + + + + + + diff --git a/partner_company_group/views/contact_view.xml b/partner_company_group/views/contact_view.xml new file mode 100644 index 000000000..8a8dc140b --- /dev/null +++ b/partner_company_group/views/contact_view.xml @@ -0,0 +1,27 @@ + + + + res.partner.form + res.partner + + + + + + + + + + res.partner.select + res.partner + + + + + + + + + + + diff --git a/partner_company_group/views/opportunity_view.xml b/partner_company_group/views/opportunity_view.xml new file mode 100644 index 000000000..548204883 --- /dev/null +++ b/partner_company_group/views/opportunity_view.xml @@ -0,0 +1,16 @@ + + + + crm.lead.search.opportunity + crm.lead + + + + + + + + + + + diff --git a/partner_company_group/views/sale_order_view.xml b/partner_company_group/views/sale_order_view.xml new file mode 100644 index 000000000..321938ef4 --- /dev/null +++ b/partner_company_group/views/sale_order_view.xml @@ -0,0 +1,16 @@ + + + + sale.order.list.select + sale.order + + + + + + + + + + +