Skip to content

Commit 16ab7c9

Browse files
yankinmaxHighcooley
authored andcommitted
[ADD] sale_partner_company_group
1 parent fb80190 commit 16ab7c9

18 files changed

+919
-0
lines changed

sale_partner_company_group/README.rst

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
==========================
2+
Sale Partner Company Group
3+
==========================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
17+
:target: https://github.com/OCA/partner-contact/tree/15.0/sale_partner_company_group
18+
:alt: OCA/partner-contact
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/partner-contact-15-0/partner-contact-15-0-sale_partner_company_group
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/134/15.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This Module adds a company group field to sale orders. For more details investigate in base_partner_company_group.
29+
30+
**Table of contents**
31+
32+
.. contents::
33+
:local:
34+
35+
Bug Tracker
36+
===========
37+
38+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_.
39+
In case of trouble, please check there if your issue has already been reported.
40+
If you spotted it first, help us smashing it by providing a detailed and welcomed
41+
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20sale_partner_company_group%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
42+
43+
Do not contact contributors directly about support or help with technical issues.
44+
45+
Credits
46+
=======
47+
48+
Authors
49+
~~~~~~~
50+
51+
* Camptocamp SA
52+
53+
Contributors
54+
~~~~~~~~~~~~
55+
56+
* Timon Tschanz <timon.tschanz@camptocamp.com>
57+
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
58+
* `Tecnativa <https://www.tecnativa.com>`_:
59+
60+
* Ernesto Tejeda
61+
62+
* Tharathip Chaweewongphan <tharathipc@ecosoft.co.th>
63+
64+
Maintainers
65+
~~~~~~~~~~~
66+
67+
This module is maintained by the OCA.
68+
69+
.. image:: https://odoo-community.org/logo.png
70+
:alt: Odoo Community Association
71+
:target: https://odoo-community.org
72+
73+
OCA, or the Odoo Community Association, is a nonprofit organization whose
74+
mission is to support the collaborative development of Odoo features and
75+
promote its widespread use.
76+
77+
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/15.0/sale_partner_company_group>`_ project on GitHub.
78+
79+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from .hooks import pre_init_hook
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2019 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
{
4+
"name": "Sale Partner Company Group",
5+
"summary": "Adds the possibility to add a company group to a company",
6+
"version": "15.0.1.0.0",
7+
"category": "Sales",
8+
"author": "Camptocamp SA, Odoo Community Association (OCA)",
9+
"license": "AGPL-3",
10+
"depends": ["base_partner_company_group", "sale"],
11+
"website": "https://github.com/OCA/partner-contact",
12+
"data": ["views/sale_order_view.xml"],
13+
"installable": True,
14+
}

sale_partner_company_group/hooks.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2022 Tecnativa - Víctor Martínez
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
import logging
4+
5+
6+
def pre_init_hook(cr):
7+
"""Prepopulate stored related fields for faster installation"""
8+
logger = logging.getLogger(__name__)
9+
logger.info("Prepopulating stored related fields")
10+
cr.execute(
11+
"""
12+
ALTER TABLE sale_order
13+
ADD COLUMN IF NOT EXISTS company_group_id integer;
14+
"""
15+
)

sale_partner_company_group/i18n/es.po

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_partner_company_group
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 13.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2020-07-03 17:19+0000\n"
10+
"Last-Translator: Sergio Teruel <sergio.teruel@tecnativa.com>\n"
11+
"Language-Team: none\n"
12+
"Language: es\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
17+
"X-Generator: Weblate 3.10\n"
18+
19+
#. module: sale_partner_company_group
20+
#: model_terms:ir.ui.view,arch_db:sale_partner_company_group.view_sales_order_filter
21+
msgid "Company Group"
22+
msgstr "Grupo compañía"
23+
24+
#. module: sale_partner_company_group
25+
#: model:ir.model.fields,field_description:sale_partner_company_group.field_sale_order__company_group_id
26+
msgid "Company group"
27+
msgstr "Grupo compañía"
28+
29+
#. module: sale_partner_company_group
30+
#: model:ir.model,name:sale_partner_company_group.model_res_partner
31+
msgid "Contact"
32+
msgstr ""
33+
34+
#. module: sale_partner_company_group
35+
#: model:ir.model,name:sale_partner_company_group.model_sale_order
36+
msgid "Sales Order"
37+
msgstr "Pedido de venta"
38+
39+
#. module: sale_partner_company_group
40+
#: code:addons/sale_partner_company_group/models/res_partner.py:0
41+
#, python-format
42+
msgid "Warning"
43+
msgstr ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_partner_company_group
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: sale_partner_company_group
17+
#: model_terms:ir.ui.view,arch_db:sale_partner_company_group.view_sales_order_filter
18+
msgid "Company Group"
19+
msgstr ""
20+
21+
#. module: sale_partner_company_group
22+
#: model:ir.model.fields,field_description:sale_partner_company_group.field_sale_order__company_group_id
23+
msgid "Company group"
24+
msgstr ""
25+
26+
#. module: sale_partner_company_group
27+
#: model:ir.model.fields,field_description:sale_partner_company_group.field_sale_order__display_name
28+
msgid "Display Name"
29+
msgstr ""
30+
31+
#. module: sale_partner_company_group
32+
#: model:ir.model.fields,field_description:sale_partner_company_group.field_sale_order__id
33+
msgid "ID"
34+
msgstr ""
35+
36+
#. module: sale_partner_company_group
37+
#: model:ir.model.fields,field_description:sale_partner_company_group.field_sale_order____last_update
38+
msgid "Last Modified on"
39+
msgstr ""
40+
41+
#. module: sale_partner_company_group
42+
#: model:ir.model,name:sale_partner_company_group.model_sale_order
43+
msgid "Sales Order"
44+
msgstr ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_partner_company_group
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: sale_partner_company_group
17+
#: model_terms:ir.ui.view,arch_db:sale_partner_company_group.view_sales_order_filter
18+
msgid "Company Group"
19+
msgstr ""
20+
21+
#. module: sale_partner_company_group
22+
#: model:ir.model.fields,field_description:sale_partner_company_group.field_sale_order__company_group_id
23+
msgid "Company group"
24+
msgstr ""
25+
26+
#. module: sale_partner_company_group
27+
#: model:ir.model,name:sale_partner_company_group.model_res_partner
28+
msgid "Contact"
29+
msgstr ""
30+
31+
#. module: sale_partner_company_group
32+
#: model:ir.model,name:sale_partner_company_group.model_sale_order
33+
msgid "Sales Order"
34+
msgstr ""
35+
36+
#. module: sale_partner_company_group
37+
#: code:addons/sale_partner_company_group/models/res_partner.py:0
38+
#, python-format
39+
msgid "Warning"
40+
msgstr ""
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_partner_company_group
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 13.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2020-03-21 14:13+0000\n"
10+
"Last-Translator: Dong <dong@freshoo.cn>\n"
11+
"Language-Team: none\n"
12+
"Language: zh_CN\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=1; plural=0;\n"
17+
"X-Generator: Weblate 3.10\n"
18+
19+
#. module: sale_partner_company_group
20+
#: model_terms:ir.ui.view,arch_db:sale_partner_company_group.view_sales_order_filter
21+
msgid "Company Group"
22+
msgstr "集团公司"
23+
24+
#. module: sale_partner_company_group
25+
#: model:ir.model.fields,field_description:sale_partner_company_group.field_sale_order__company_group_id
26+
msgid "Company group"
27+
msgstr "集团公司"
28+
29+
#. module: sale_partner_company_group
30+
#: model:ir.model,name:sale_partner_company_group.model_res_partner
31+
msgid "Contact"
32+
msgstr ""
33+
34+
#. module: sale_partner_company_group
35+
#: model:ir.model,name:sale_partner_company_group.model_sale_order
36+
msgid "Sales Order"
37+
msgstr "销售订单"
38+
39+
#. module: sale_partner_company_group
40+
#: code:addons/sale_partner_company_group/models/res_partner.py:0
41+
#, python-format
42+
msgid "Warning"
43+
msgstr ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import sale_order
2+
from . import res_partner
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright 2019 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import _, api, models
5+
6+
7+
class Contact(models.Model):
8+
_inherit = "res.partner"
9+
10+
@api.onchange("company_group_id")
11+
def _onchange_company_group_id(self):
12+
res = {}
13+
if (
14+
self.company_group_id
15+
and self.company_group_id.property_product_pricelist
16+
!= self.property_product_pricelist
17+
):
18+
res["warning"] = {
19+
"title": _("Warning"),
20+
"message": _(
21+
f"The company group {self.company_group_id.display_name} has the pricelist "
22+
f"{self.company_group_id.property_product_pricelist.display_name}, "
23+
"that is different than the pricelist set on this contact"
24+
),
25+
}
26+
return res
27+
28+
@api.onchange("property_product_pricelist")
29+
def _onchange_property_product_pricelist(self):
30+
res = self._onchange_company_group_id()
31+
if (
32+
not res
33+
and self.company_group_member_ids
34+
# Need to check _origin because the field company_group_ids is a recordset of
35+
# NewIds that have False values on the field property_product_pricelist.
36+
and self.company_group_member_ids._origin.mapped(
37+
"property_product_pricelist"
38+
)
39+
- self.property_product_pricelist
40+
):
41+
company_members = self.company_group_member_ids.filtered(
42+
lambda cm: cm.property_product_pricelist
43+
!= self.property_product_pricelist
44+
)
45+
members_str = ""
46+
for member in company_members:
47+
members_str += "\t- %s\n" % member.display_name
48+
res["warning"] = {
49+
"title": _("Warning"),
50+
"message": _(
51+
"This contact has members of a company group with"
52+
f" different pricelists, the members are:\n{members_str}"
53+
),
54+
}
55+
return res
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2019 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import fields, models
5+
6+
7+
class SaleOrder(models.Model):
8+
_inherit = "sale.order"
9+
10+
company_group_id = fields.Many2one(
11+
related="partner_id.company_group_id", store=True
12+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* Timon Tschanz <timon.tschanz@camptocamp.com>
2+
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
3+
* `Tecnativa <https://www.tecnativa.com>`_:
4+
5+
* Ernesto Tejeda
6+
7+
* Tharathip Chaweewongphan <tharathipc@ecosoft.co.th>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This Module adds a company group field to sale orders. For more details investigate in base_partner_company_group.
Loading

0 commit comments

Comments
 (0)