diff --git a/product_update_price_last_purchase/__manifest__.py b/product_update_price_last_purchase/__manifest__.py index c044cbb..1cd63ae 100644 --- a/product_update_price_last_purchase/__manifest__.py +++ b/product_update_price_last_purchase/__manifest__.py @@ -22,7 +22,6 @@ "data": [ "views/actions.xml", "views/product_view.xml", - "views/res_config.xml", ], "installable": True, } diff --git a/product_update_price_last_purchase/models/__init__.py b/product_update_price_last_purchase/models/__init__.py index 6440ced..fb351a4 100644 --- a/product_update_price_last_purchase/models/__init__.py +++ b/product_update_price_last_purchase/models/__init__.py @@ -1,4 +1,3 @@ from . import product_template from . import product_product -from . import res_config from . import stock_move diff --git a/product_update_price_last_purchase/models/product_product.py b/product_update_price_last_purchase/models/product_product.py index ca2d585..dbdacbc 100644 --- a/product_update_price_last_purchase/models/product_product.py +++ b/product_update_price_last_purchase/models/product_product.py @@ -41,10 +41,10 @@ class ProductProduct(models.Model): return res def use_theoretical_price(self): - res = super().use_theoretical_price() for product in self: - product.to_print_label = True - return res + if product.last_purchase_price_received_compute_type != "manual_update": + product.lst_price = product.theoretical_price + product.to_print_label = True class ProductPackaging(models.Model): diff --git a/product_update_price_last_purchase/models/product_template.py b/product_update_price_last_purchase/models/product_template.py index a6c766e..7f8e08e 100644 --- a/product_update_price_last_purchase/models/product_template.py +++ b/product_update_price_last_purchase/models/product_template.py @@ -45,6 +45,7 @@ class ProductTemplate(models.Model): [ ("without_discounts", "Without discounts"), ("with_discount", "First discount"), + ("with_two_discounts", "Double discount"), ("with_three_discounts", "Triple discount"), ("manual_update", "Manual update"), ], @@ -56,6 +57,8 @@ class ProductTemplate(models.Model): the last purchase price.\n * First discount: take into account only first discount when updating the last purchase price.\n + * Double discount: take into account two first discounts when updating + the last purchase price.\n * Triple discount: take into account all discounts when updating the last purchase price. Needs "Purchase Triple Discount" OCA module.\n diff --git a/product_update_price_last_purchase/models/res_config.py b/product_update_price_last_purchase/models/res_config.py deleted file mode 100644 index a44ac0b..0000000 --- a/product_update_price_last_purchase/models/res_config.py +++ /dev/null @@ -1,12 +0,0 @@ -from odoo import fields, models - - -class ResConfigSettings(models.TransientModel): - _inherit = "res.config.settings" - - product_pricelist_automatic = fields.Many2one( - required=False, - comodel_name="product.pricelist", - string="Pricelist applied to automatic calculation of sales price", - config_parameter="product_update_price_last_purchase.product_pricelist_automatic", - ) diff --git a/product_update_price_last_purchase/models/stock_move.py b/product_update_price_last_purchase/models/stock_move.py index aad3091..10c7675 100644 --- a/product_update_price_last_purchase/models/stock_move.py +++ b/product_update_price_last_purchase/models/stock_move.py @@ -18,6 +18,7 @@ class StockMove(models.Model): def product_price_update_before_done(self): res = super(StockMove, self).product_price_update_before_done() for move in self.filtered(lambda move: move.location_id.usage == "supplier"): + _logger.warning("move: %s" % move) if ( move.product_id.last_purchase_price_received_compute_type == "with_three_discounts" @@ -36,6 +37,17 @@ class StockMove(models.Model): * (1 - move.purchase_line_id.discount / 100), precision_digits=2, ) + elif ( + move.product_id.last_purchase_price_received_compute_type + == "with_two_discounts" + ): + price_updated = float_round( + move.purchase_line_id.price_unit + * (1 - move.purchase_line_id.discount / 100) + * (1 - move.purchase_line_id.discount2 / 100), + precision_digits=2, + ) + else: price_updated = move.purchase_line_id.price_unit @@ -57,4 +69,4 @@ class StockMove(models.Model): move.product_id.with_company(move.company_id.id).sudo().write( {"last_purchase_price_received": price_updated} ) - return res + return res diff --git a/product_update_price_last_purchase/views/res_config.xml b/product_update_price_last_purchase/views/res_config.xml deleted file mode 100644 index 1903939..0000000 --- a/product_update_price_last_purchase/views/res_config.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - product.update.price.last.purchase.res.config.settings.form - res.config.settings - - - - -
-
-
-
-
-
-
-
-