product_update_price_last_purchase: add double discount to compute options
This commit is contained in:
parent
b16d09ded7
commit
39dd06bacc
7 changed files with 19 additions and 50 deletions
|
|
@ -22,7 +22,6 @@
|
|||
"data": [
|
||||
"views/actions.xml",
|
||||
"views/product_view.xml",
|
||||
"views/res_config.xml",
|
||||
],
|
||||
"installable": True,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
from . import product_template
|
||||
from . import product_product
|
||||
from . import res_config
|
||||
from . import stock_move
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ class ProductProduct(models.Model):
|
|||
return res
|
||||
|
||||
def use_theoretical_price(self):
|
||||
res = super().use_theoretical_price()
|
||||
for product in self:
|
||||
if product.last_purchase_price_received_compute_type != "manual_update":
|
||||
product.lst_price = product.theoretical_price
|
||||
product.to_print_label = True
|
||||
return res
|
||||
|
||||
|
||||
class ProductPackaging(models.Model):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
)
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record
|
||||
id="res_config_settings_view_form__compute_pvp_pricelist"
|
||||
model="ir.ui.view"
|
||||
>
|
||||
<field
|
||||
name="name"
|
||||
>product.update.price.last.purchase.res.config.settings.form</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="priority" eval="120" />
|
||||
<field name="inherit_id" ref="sale.res_config_settings_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@id='pricing_setting_container']" position="inside">
|
||||
<div
|
||||
class="col-12 col-lg-6 o_setting_box"
|
||||
name="update_price_settigs_container"
|
||||
>
|
||||
<div class="o_setting_right_pane">
|
||||
<label
|
||||
for="product_pricelist_automatic"
|
||||
string="PVP Pricelist"
|
||||
/>
|
||||
<field name="product_pricelist_automatic" />
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue