Browse Source

[MIG] v16.0

16.0
RemiFr82 11 months ago
parent
commit
25a8670f63
  1. 17
      membership_initial_discount/models/account_move_line.py
  2. 6
      membership_initial_discount/models/product_product.py
  3. 6
      membership_initial_discount/models/product_template.py

17
membership_initial_discount/models/account_move_line.py

@ -6,16 +6,17 @@ from odoo import api, models, _
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
def _get_computed_price_unit(self):
res = super()._get_computed_price_unit()
if self.move_id.is_invoice() and self.initial_membership_check():
product = self.product_id
if product.initial_discount == "fixed" and product.fixed_discount:
res -= product.fixed_discount
return res
@api.depends("product_id", "product_uom_id")
def _compute_price_unit(self):
super()._compute_price_unit()
for line in self:
if line.move_id.is_invoice() and line.initial_membership_check():
product = line.product_id
if product.initial_discount == "fixed" and product.fixed_discount:
line.price_unit -= product.fixed_discount
@api.onchange("product_id")
def _onchange_product_id(self):
def _inverse_product_id(self):
super()._onchange_product_id()
for line in self:
if not line.product_id or line.display_type in (

6
membership_initial_discount/models/product_product.py

@ -2,12 +2,6 @@
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
DISCOUNTS = [
("none", _("No initial discount")),
("fixed", _("Fixed amount")),
("percent", _("Percentage of the price")),
]
class ProductProduct(models.Model):
_inherit = "product.product"

6
membership_initial_discount/models/product_template.py

@ -3,9 +3,9 @@ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
DISCOUNTS = [
("none", _("No initial discount")),
("fixed", _("Fixed amount")),
("percent", _("Percentage of the price")),
("none", "No initial discount"),
("fixed", "Fixed amount"),
("percent", "Percentage of the price"),
]

Loading…
Cancel
Save