Skip to content

Commit

Permalink
[IMP] add testing cost to category to use massively
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Dec 5, 2024
1 parent 4ec83b5 commit e0d0d33
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions product_managed_replenishment_cost/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"security/replenishment_cost_security.xml",
"views/product_supplierinfo.xml",
"views/replenishment_menu.xml",
"views/product_category.xml",
"views/product_product.xml",
"views/product_template.xml",
],
Expand Down
1 change: 1 addition & 0 deletions product_managed_replenishment_cost/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import replenishment_cost
from . import product_category
from . import product_product
from . import product_supplierinfo
14 changes: 12 additions & 2 deletions product_managed_replenishment_cost/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _compute_testing_cost(self):

def _inverse_testing_cost(self):
if len(self.product_variant_ids) == 1:
self.product_variant_ids.testing_cost = self.testing_cost
self.product_variant_ids.categ_id.testing_cost = self.testing_cost

def _search_testing_cost(self, operator, value):
products = self.env["product.product"].search(
Expand Down Expand Up @@ -137,9 +137,11 @@ class ProductProduct(models.Model):
)
testing_cost = fields.Float(
string="Testing Cost (€/pz)",
company_dependent=True,
groups="base.group_user",
compute="_compute_testing_cost",
digits="Product Price",
store=True,
readonly=False,
)
landed_cost = fields.Float(
string="Landed cost",
Expand All @@ -153,6 +155,14 @@ class ProductProduct(models.Model):
string="Landed with adjustment/depreciation/testing"
)

@api.depends("categ_id.testing_cost")
def _compute_testing_cost(self):
for product in self:
product.testing_cost = product.categ_id.testing_cost

def _inverse_testing_cost(self):
self.categ_id.testing_cost = self.testing_cost

@api.depends(
"seller_ids",
"seller_ids.price",
Expand Down

0 comments on commit e0d0d33

Please sign in to comment.