Browse Source

Merge PR #1257 into 14.0

Signed-off-by pedrobaeza
14.0
OCA-git-bot 3 years ago
parent
commit
9d6e953abb
  1. 47
      partner_company_group/i18n/es.po
  2. 26
      partner_company_group/i18n/partner_company_group.pot
  3. 53
      partner_company_group/models/res_partner.py
  4. 1
      partner_company_group/readme/CONTRIBUTORS.rst
  5. 121
      partner_company_group/tests/test_partner_company_group.py
  6. 10
      partner_company_group/views/contact_view.xml

47
partner_company_group/i18n/es.po

@ -6,15 +6,16 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2020-07-03 17:19+0000\n"
"POT-Creation-Date: 2022-04-11 11:02+0000\n"
"PO-Revision-Date: 2022-04-11 13:05+0200\n"
"Last-Translator: Sergio Teruel <sergio.teruel@tecnativa.com>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.10\n"
"X-Generator: Poedit 2.3\n"
#. module: partner_company_group
#: model_terms:ir.ui.view,arch_db:partner_company_group.view_account_invoice_filter
@ -36,10 +37,11 @@ msgid "Company group"
msgstr "Grupo compañía"
#. module: partner_company_group
#: model:ir.actions.act_window,name:partner_company_group.action_open_group_members
#: model:ir.model.fields,field_description:partner_company_group.field_res_partner__company_group_member_ids
#: model:ir.model.fields,field_description:partner_company_group.field_res_users__company_group_member_ids
msgid "Company group members"
msgstr ""
msgstr "Miembros del grupo compañía"
#. module: partner_company_group
#: model:ir.model,name:partner_company_group.model_res_partner
@ -52,7 +54,7 @@ msgstr "Contacto"
#: model:ir.model.fields,field_description:partner_company_group.field_res_partner__display_name
#: model:ir.model.fields,field_description:partner_company_group.field_sale_order__display_name
msgid "Display Name"
msgstr ""
msgstr "Nombre mostrado"
#. module: partner_company_group
#: model:ir.model.fields,field_description:partner_company_group.field_account_move__id
@ -60,12 +62,12 @@ msgstr ""
#: model:ir.model.fields,field_description:partner_company_group.field_res_partner__id
#: model:ir.model.fields,field_description:partner_company_group.field_sale_order__id
msgid "ID"
msgstr ""
msgstr "ID"
#. module: partner_company_group
#: model:ir.model,name:partner_company_group.model_account_move
msgid "Journal Entry"
msgstr ""
msgstr "Asiento contable"
#. module: partner_company_group
#: model:ir.model.fields,field_description:partner_company_group.field_account_move____last_update
@ -73,7 +75,7 @@ msgstr ""
#: model:ir.model.fields,field_description:partner_company_group.field_res_partner____last_update
#: model:ir.model.fields,field_description:partner_company_group.field_sale_order____last_update
msgid "Last Modified on"
msgstr ""
msgstr "Última modificación en"
#. module: partner_company_group
#: model:ir.model,name:partner_company_group.model_crm_lead
@ -85,5 +87,30 @@ msgstr "Iniciativa / Oportunidad"
msgid "Sales Order"
msgstr "Pedido de venta"
#~ msgid "Journal Entries"
#~ msgstr "Asientos contables"
#. module: partner_company_group
#: code:addons/partner_company_group/models/res_partner.py:0
#, python-format
msgid ""
"The company group %s has the pricelist %s, that is different than the "
"pricelist set on this contact"
msgstr ""
"El grupo compañía %s tiene la tarifa %s, que es diferente a la tarifa de "
"este contacto"
#. module: partner_company_group
#: code:addons/partner_company_group/models/res_partner.py:0
#, python-format
msgid ""
"This contact has members of a company group with different pricelists, the "
"members are:\n"
"%s"
msgstr ""
"Este contacto tiene miembros de un grupo compañía con diferentes tarifas, "
"los miembros son:\n"
"%s"
#. module: partner_company_group
#: code:addons/partner_company_group/models/res_partner.py:0
#, python-format
msgid "Warning"
msgstr "Advertencia"

26
partner_company_group/i18n/partner_company_group.pot

@ -6,6 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-11 11:02+0000\n"
"PO-Revision-Date: 2022-04-11 11:02+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -33,6 +35,7 @@ msgid "Company group"
msgstr ""
#. module: partner_company_group
#: model:ir.actions.act_window,name:partner_company_group.action_open_group_members
#: model:ir.model.fields,field_description:partner_company_group.field_res_partner__company_group_member_ids
#: model:ir.model.fields,field_description:partner_company_group.field_res_users__company_group_member_ids
msgid "Company group members"
@ -81,3 +84,26 @@ msgstr ""
#: model:ir.model,name:partner_company_group.model_sale_order
msgid "Sales Order"
msgstr ""
#. module: partner_company_group
#: code:addons/partner_company_group/models/res_partner.py:0
#, python-format
msgid ""
"The company group %s has the pricelist %s, that is different than the "
"pricelist set on this contact"
msgstr ""
#. module: partner_company_group
#: code:addons/partner_company_group/models/res_partner.py:0
#, python-format
msgid ""
"This contact has members of a company group with different pricelists, the members are:\n"
"%s"
msgstr ""
#. module: partner_company_group
#: code:addons/partner_company_group/models/res_partner.py:0
#: code:addons/partner_company_group/models/res_partner.py:0
#, python-format
msgid "Warning"
msgstr ""

53
partner_company_group/models/res_partner.py

@ -1,7 +1,7 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
from odoo import _, api, fields, models
class Contact(models.Model):
@ -18,3 +18,54 @@ class Contact(models.Model):
def _commercial_fields(self):
return super()._commercial_fields() + ["company_group_id"]
@api.onchange("company_group_id")
def _onchange_company_group_id(self):
res = {}
if (
self.company_group_id
and self.company_group_id.property_product_pricelist
!= self.property_product_pricelist
):
res["warning"] = {
"title": _("Warning"),
"message": _(
"The company group %s has the pricelist %s, that is different than"
" the pricelist set on this contact"
)
% (
self.company_group_id.display_name,
self.company_group_id.property_product_pricelist.display_name,
),
}
return res
@api.onchange("property_product_pricelist")
def _onchange_property_product_pricelist(self):
res = self._onchange_company_group_id()
if (
not res
and self.company_group_member_ids
# Need to check _origin because the field company_group_ids is a recordset of
# NewIds that have False values on the field property_product_pricelist.
and self.company_group_member_ids._origin.mapped(
"property_product_pricelist"
)
- self.property_product_pricelist
):
company_members = self.company_group_member_ids.filtered(
lambda cm: cm.property_product_pricelist
!= self.property_product_pricelist
)
members_str = ""
for member in company_members:
members_str += "\t- %s\n" % member.display_name
res["warning"] = {
"title": _("Warning"),
"message": _(
"This contact has members of a company group with"
" different pricelists, the members are:\n%s"
)
% members_str,
}
return res

1
partner_company_group/readme/CONTRIBUTORS.rst

@ -3,5 +3,6 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Ernesto Tejeda
* Carlos Roca
* Tharathip Chaweewongphan <tharathipc@ecosoft.co.th>

121
partner_company_group/tests/test_partner_company_group.py

@ -1,20 +1,125 @@
# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
from odoo.tests.common import SavepointCase
class TestPartnerCompanyGroup(TransactionCase):
def setUp(self):
super().setUp()
self.partner_model = self.env["res.partner"]
self.company = self.partner_model.create(
class TestPartnerCompanyGroup(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.partner_model = cls.env["res.partner"]
cls.company = cls.partner_model.create(
{"name": "Test Company", "company_type": "company"}
)
self.contact = self.partner_model.create(
{"name": "Test Contact", "type": "contact", "parent_id": self.company.id}
cls.contact = cls.partner_model.create(
{"name": "Test Contact", "type": "contact", "parent_id": cls.company.id}
)
currency = cls.env.ref("base.USD")
cls.pricelist1 = cls.env["product.pricelist"].create(
{"name": "Pricelist 01", "currency_id": currency.id}
)
cls.pricelist2 = cls.env["product.pricelist"].create(
{"name": "Pricelist 02", "currency_id": currency.id}
)
cls.company_group1 = cls.env["res.partner"].create(
{
"name": "Company Group 01",
"is_company": True,
"property_product_pricelist": cls.pricelist1.id,
}
)
cls.company_group2 = cls.env["res.partner"].create(
{
"name": "Company Group 02",
"is_company": True,
"property_product_pricelist": cls.pricelist2.id,
}
)
cls.partner1 = cls.env["res.partner"].create(
{
"name": "Partner 01",
"is_company": True,
"property_product_pricelist": cls.pricelist1.id,
"company_group_id": cls.company_group1.id,
}
)
cls.partner2 = cls.env["res.partner"].create(
{
"name": "Partner 02",
"is_company": True,
"property_product_pricelist": cls.pricelist1.id,
"company_group_id": cls.company_group1.id,
}
)
def test_partner_company_group(self):
self.company.write({"company_group_id": self.company.id})
self.assertEqual(self.company.company_group_id, self.contact.company_group_id)
def test_01_change_pricelist_partner(self):
self.partner1.property_product_pricelist = self.pricelist2
res = self.partner1._onchange_property_product_pricelist()
self.assertEqual(
{
"warning": {
"title": "Warning",
"message": "The company group Company Group 01 has the pricelist "
"Pricelist 01 (USD), that is different than the "
"pricelist set on this contact",
}
},
res,
)
self.partner1.property_product_pricelist = self.pricelist1
res = self.partner1._onchange_property_product_pricelist()
self.assertEqual({}, res)
def test_02_change_company_group_partner(self):
self.partner1.company_group_id = self.company_group2
res = self.partner1._onchange_company_group_id()
self.assertEqual(
{
"warning": {
"title": "Warning",
"message": "The company group Company Group 02 has the pricelist "
"Pricelist 02 (USD), that is different than the "
"pricelist set on this contact",
}
},
res,
)
self.partner1.company_group_id = self.company_group1
res = self.partner1._onchange_company_group_id()
self.assertEqual({}, res)
def test_03_change_pricelist_company_group(self):
self.company_group1.property_product_pricelist = self.pricelist2
res = self.company_group1._onchange_property_product_pricelist()
self.assertEqual(
{
"warning": {
"title": "Warning",
"message": "This contact has members of a company group with "
"different pricelists, the members are:\n"
"\t- Partner 01\n\t- Partner 02\n",
}
},
res,
)
self.partner1.property_product_pricelist = self.pricelist2
res = self.company_group1._onchange_property_product_pricelist()
self.assertEqual(
{
"warning": {
"title": "Warning",
"message": "This contact has members of a company group with "
"different pricelists, the members are:\n"
"\t- Partner 02\n",
}
},
res,
)
self.partner2.property_product_pricelist = self.pricelist2
res = self.company_group1._onchange_property_product_pricelist()
self.assertEqual({}, res)

10
partner_company_group/views/contact_view.xml

@ -30,4 +30,14 @@
</filter>
</field>
</record>
<record id="action_open_group_members" model="ir.actions.act_window">
<field name="name">Company group members</field>
<field name="res_model">res.partner</field>
<field name="binding_model_id" ref="model_res_partner" />
<field name="view_mode">tree</field>
<field name="target">current</field>
<field
name="domain"
>[('company_group_id', 'in', context.get('active_ids'))]</field>
</record>
</odoo>
Loading…
Cancel
Save