mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[MIG] base_global_discount: Migration to 17.0
This commit is contained in:
@@ -14,7 +14,7 @@ class GlobalDiscount(models.Model):
|
||||
discount_scope = fields.Selection(
|
||||
selection=[("sale", "Sales"), ("purchase", "Purchases")],
|
||||
default="sale",
|
||||
required="True",
|
||||
required=True,
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
@@ -22,11 +22,9 @@ class GlobalDiscount(models.Model):
|
||||
default=lambda self: self.env.company,
|
||||
)
|
||||
|
||||
def name_get(self):
|
||||
result = []
|
||||
def _compute_display_name(self):
|
||||
for one in self:
|
||||
result.append((one.id, f"{one.name} ({one.discount:.2f}%)"))
|
||||
return result
|
||||
one.display_name = f"{one.name} ({one.discount:.2f}%)"
|
||||
|
||||
def _get_global_discount_vals(self, base, **kwargs):
|
||||
"""Prepare the dict of values to create to obtain the discounted
|
||||
|
||||
@@ -15,6 +15,7 @@ class ProductTemplate(models.Model):
|
||||
),
|
||||
compute="_compute_bypass_global_discount",
|
||||
inverse="_inverse_bypass_global_discount",
|
||||
search="_search_bypass_global_discount",
|
||||
)
|
||||
|
||||
def _search_bypass_global_discount(self, operator, value):
|
||||
@@ -31,9 +32,12 @@ class ProductTemplate(models.Model):
|
||||
template.bypass_global_discount = (
|
||||
template.product_variant_ids.bypass_global_discount
|
||||
)
|
||||
else:
|
||||
template.bypass_global_discount = False
|
||||
|
||||
def _inverse_bypass_global_discount(self):
|
||||
if len(self.product_variant_ids) == 1:
|
||||
self.product_variant_ids.bypass_global_discount = (
|
||||
self.bypass_global_discount
|
||||
)
|
||||
for template in self:
|
||||
if len(template.product_variant_ids) == 1:
|
||||
template.product_variant_ids.bypass_global_discount = (
|
||||
template.bypass_global_discount
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user