mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[MIG] base_global_discount: Migration to 14.0
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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';
|
||||
""",
|
||||
)
|
||||
@@ -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';
|
||||
"""
|
||||
)
|
||||
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -5,3 +5,4 @@
|
||||
* Carlos Dauden
|
||||
* Rafael Blasco
|
||||
* Ernesto Tejeda
|
||||
* Omar Castiñeira <omar@comunitea.com>
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user