[MIG] base_global_discount: Migration to 13.0

[UPD] Update base_global_discount.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-backend-13.0/server-backend-13.0-base_global_discount
Translate-URL: https://translation.odoo-community.org/projects/server-backend-13-0/server-backend-13-0-base_global_discount/
This commit is contained in:
Ernesto Tejeda
2020-11-03 19:07:07 -05:00
committed by Omar (Comunitea)
parent bfda1e6a6a
commit b215abe4f7
15 changed files with 85 additions and 40 deletions

View File

@@ -14,13 +14,13 @@ Base Global Discount
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
:target: https://github.com/OCA/server-backend/tree/12.0/base_global_discount
:target: https://github.com/OCA/server-backend/tree/13.0/base_global_discount
:alt: OCA/server-backend
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-backend-12-0/server-backend-12-0-base_global_discount
:target: https://translation.odoo-community.org/projects/server-backend-13-0/server-backend-13-0-base_global_discount
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/253/12.0
:target: https://runbot.odoo-community.org/runbot/253/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -50,9 +50,8 @@ You can assign global discounts to partners as well:
#. Go to a partner that is a company.
#. Go to the *Sales & Purchases* tab.
#. In section sale (if the partner is a customer), you can set sale discounts.
#. In section purchase (if the partner is a supplier), you can set purchase
discounts.
#. In section sale, you can set sale discounts.
#. In section purchase, you can set purchase discounts.
Bug Tracker
===========
@@ -60,7 +59,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_global_discount%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_global_discount%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -81,6 +80,7 @@ Contributors
* David Vidal
* Carlos Dauden
* Rafael Blasco
* Ernesto Tejeda
Maintainers
~~~~~~~~~~~
@@ -95,6 +95,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/12.0/base_global_discount>`_ project on GitHub.
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/13.0/base_global_discount>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -3,12 +3,12 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Base Global Discount",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"category": "Base",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-backend",
"license": "AGPL-3",
"depends": ["product",],
"depends": ["product"],
"data": [
"security/ir.model.access.csv",
"security/security.xml",

View File

@@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_global_discount
# * base_global_discount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -98,7 +98,7 @@ msgid "Purchase Global Discounts"
msgstr ""
#. module: base_global_discount
#: selection:global.discount,discount_scope:0
#: model:ir.model.fields.selection,name:base_global_discount.selection__global_discount__discount_scope__purchase
msgid "Purchases"
msgstr ""
@@ -109,7 +109,7 @@ msgid "Sale Global Discounts"
msgstr ""
#. module: base_global_discount
#: selection:global.discount,discount_scope:0
#: model:ir.model.fields.selection,name:base_global_discount.selection__global_discount__discount_scope__sale
msgid "Sales"
msgstr ""
@@ -117,4 +117,3 @@ msgstr ""
#: model:ir.model.fields,field_description:base_global_discount.field_global_discount__sequence
msgid "Sequence"
msgstr ""

View File

@@ -101,7 +101,7 @@ msgid "Purchase Global Discounts"
msgstr "Descuentos globales de compra"
#. module: base_global_discount
#: selection:global.discount,discount_scope:0
#: model:ir.model.fields.selection,name:base_global_discount.selection__global_discount__discount_scope__purchase
msgid "Purchases"
msgstr "Compras"
@@ -112,7 +112,7 @@ msgid "Sale Global Discounts"
msgstr "Descuentos de venta globales"
#. module: base_global_discount
#: selection:global.discount,discount_scope:0
#: model:ir.model.fields.selection,name:base_global_discount.selection__global_discount__discount_scope__sale
msgid "Sales"
msgstr "Ventas"

View File

@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_global_discount
# * base_global_discount
#
msgid ""
msgstr ""
@@ -101,7 +101,7 @@ msgid "Purchase Global Discounts"
msgstr "Descontos Globais de Compras"
#. module: base_global_discount
#: selection:global.discount,discount_scope:0
#: model:ir.model.fields.selection,name:base_global_discount.selection__global_discount__discount_scope__purchase
msgid "Purchases"
msgstr "Compras"
@@ -112,7 +112,7 @@ msgid "Sale Global Discounts"
msgstr "Descontos Globais de Vendas"
#. module: base_global_discount
#: selection:global.discount,discount_scope:0
#: model:ir.model.fields.selection,name:base_global_discount.selection__global_discount__discount_scope__sale
msgid "Sales"
msgstr "Vendas"

View File

@@ -0,0 +1,36 @@
# Copyright 2020 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"""
INSERT INTO customer_global_discount_rel
(partner_id, global_discount_id)
SELECT
partner_id,
global_discount_id
FROM
global_discount_res_partner_rel
WHERE
discount_scope = 'sale';
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO supplier_global_discount_rel
(partner_id, global_discount_id)
SELECT
partner_id,
field_id
FROM
global_discount_res_partner_rel
WHERE
discount_scope = 'purchase';
""",
)

View File

@@ -0,0 +1,13 @@
# Copyright 2020 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
def migrate(cr, version):
if not version:
return
cr.execute(
"""
DELETE FROM ir_model_relation
WHERE name = 'global_discount_res_partner_rel';
"""
)

View File

@@ -2,21 +2,17 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo.addons import decimal_precision as dp
class GlobalDiscount(models.Model):
_name = "global.discount"
_description = "Global Discount"
_order = "sequence, id desc"
sequence = fields.Integer(help="Gives the order to apply discounts",)
name = fields.Char(string="Discount Name", required=True,)
discount = fields.Float(
digits=dp.get_precision("Discount"), required=True, default=0.0,
)
sequence = fields.Integer(help="Gives the order to apply discounts")
name = fields.Char(string="Discount Name", required=True)
discount = fields.Float(digits="Discount", required=True, default=0.0)
discount_scope = fields.Selection(
selection=[("sale", "Sales"), ("purchase", "Purchases"),],
selection=[("sale", "Sales"), ("purchase", "Purchases")],
default="sale",
required="True",
string="Discount Scope",
@@ -24,7 +20,7 @@ class GlobalDiscount(models.Model):
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
default=lambda self: self.env.user.company_id,
default=lambda self: self.env.company,
)
def name_get(self):

View File

@@ -8,6 +8,7 @@ class ResPartner(models.Model):
customer_global_discount_ids = fields.Many2many(
comodel_name="global.discount",
relation="customer_global_discount_rel",
column1="partner_id",
column2="global_discount_id",
string="Sale Global Discounts",
@@ -15,6 +16,7 @@ class ResPartner(models.Model):
)
supplier_global_discount_ids = fields.Many2many(
comodel_name="global.discount",
relation="supplier_global_discount_rel",
column1="partner_id",
column2="global_discount_id",
string="Purchase Global Discounts",

View File

@@ -4,3 +4,4 @@
* David Vidal
* Carlos Dauden
* Rafael Blasco
* Ernesto Tejeda

View File

@@ -2,6 +2,5 @@ You can assign global discounts to partners as well:
#. Go to a partner that is a company.
#. Go to the *Sales & Purchases* tab.
#. In section sale (if the partner is a customer), you can set sale discounts.
#. In section purchase (if the partner is a supplier), you can set purchase
discounts.
#. In section sale, you can set sale discounts.
#. In section purchase, you can set purchase discounts.

View File

@@ -7,7 +7,7 @@
<field name="model_id" ref="base_global_discount.model_global_discount" />
<field
name="domain_force"
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
>['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
<field name="perm_read" eval="1" />
<field name="perm_create" eval="1" />
<field name="perm_write" eval="1" />

View File

@@ -9,10 +9,10 @@ class TestGlobalDiscount(common.SavepointCase):
super().setUpClass()
cls.global_discount_obj = cls.env["global.discount"]
cls.global_discount_1 = cls.global_discount_obj.create(
{"name": "Test Discount 1", "discount_scope": "sale", "discount": 20,}
{"name": "Test Discount 1", "discount_scope": "sale", "discount": 20}
)
cls.global_discount_2 = cls.global_discount_obj.create(
{"name": "Test Discount 2", "discount_scope": "sale", "discount": 30,}
{"name": "Test Discount 2", "discount_scope": "sale", "discount": 30}
)
def test_01_global_discounts(self):

View File

@@ -34,7 +34,6 @@
<field name="name">Global Discounts</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">global.discount</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem

View File

@@ -10,14 +10,14 @@
<field
name="customer_global_discount_ids"
widget="many2many_tags"
attrs="{'invisible': [('customer', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"
attrs="{'invisible': [('is_company', '=', False), ('parent_id', '!=', False)]}"
/>
</group>
<group name="purchase" position="inside">
<field
name="supplier_global_discount_ids"
widget="many2many_tags"
attrs="{'invisible': [('supplier', '=', False), ('is_company', '=', False), ('parent_id', '!=', False)]}"
attrs="{'invisible': [('is_company', '=', False), ('parent_id', '!=', False)]}"
/>
</group>
</field>