Browse Source

[MIG] base_global_discount: Migration to 14.0

14.0
Omar (Comunitea) 3 years ago
parent
commit
dfd3842f11
  1. 2
      base_global_discount/__manifest__.py
  2. 36
      base_global_discount/migrations/13.0.1.0.0/post-migration.py
  3. 13
      base_global_discount/migrations/13.0.1.0.0/pre-migration.py
  4. 8
      base_global_discount/models/global_discount.py
  5. 2
      base_global_discount/models/res_partner.py
  6. 1
      base_global_discount/readme/CONTRIBUTORS.rst
  7. 1
      base_global_discount/views/res_partner_views.xml
  8. 1
      setup/base_global_discount/odoo/addons/base_global_discount
  9. 6
      setup/base_global_discount/setup.py

2
base_global_discount/__manifest__.py

@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Base Global Discount",
"version": "13.0.2.0.0",
"version": "14.0.1.0.0",
"category": "Base",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-backend",

36
base_global_discount/migrations/13.0.1.0.0/post-migration.py

@ -1,36 +0,0 @@
# 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';
""",
)

13
base_global_discount/migrations/13.0.1.0.0/pre-migration.py

@ -1,13 +0,0 @@
# 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';
"""
)

8
base_global_discount/models/global_discount.py

@ -30,11 +30,11 @@ class GlobalDiscount(models.Model):
return result
def _get_global_discount_vals(self, base, **kwargs):
""" Prepare the dict of values to create to obtain the discounted
amount
"""Prepare the dict of values to create to obtain the discounted
amount
:param float base: the amount to discount
:return: dict with the discounted amount
:param float base: the amount to discount
:return: dict with the discounted amount
"""
self.ensure_one()
return {

2
base_global_discount/models/res_partner.py

@ -25,7 +25,7 @@ class ResPartner(models.Model):
# HACK: Looks like UI doesn't behave well with Many2many fields and
# negative groups when the same field is shown. In this case, we want to
# show the readonly version to any not in the global discount group.
# TODO: Check in v14 if it's fixed
# TODO: Check in future versions if it's fixed
customer_global_discount_ids_readonly = fields.Many2many(
string="Sale Global Discounts (readonly)",
related="customer_global_discount_ids",

1
base_global_discount/readme/CONTRIBUTORS.rst

@ -5,3 +5,4 @@
* Carlos Dauden
* Rafael Blasco
* Ernesto Tejeda
* Omar Castiñeira <omar@comunitea.com>

1
base_global_discount/views/res_partner_views.xml

@ -19,6 +19,7 @@
widget="many2many_tags"
groups="!base_global_discount.group_global_discount"
attrs="{'invisible': [('is_company', '=', False), ('parent_id', '!=', False)]}"
readonly="1"
/>
</group>
<group name="purchase" position="inside">

1
setup/base_global_discount/odoo/addons/base_global_discount

@ -0,0 +1 @@
../../../../base_global_discount

6
setup/base_global_discount/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading…
Cancel
Save