diff --git a/beesdoo_product/models/beesdoo_product.py b/beesdoo_product/models/beesdoo_product.py
index c460a9a..2195e5d 100644
--- a/beesdoo_product/models/beesdoo_product.py
+++ b/beesdoo_product/models/beesdoo_product.py
@@ -11,6 +11,19 @@ from odoo.tools.translate import _
_logger = logging.getLogger(__name__)
+class ResPartner(models.Model):
+ _inherit = "res.partner"
+
+ profit_margin = fields.Float(string="Product Margin [%]")
+
+ @api.multi
+ @api.constrains("profit_margin")
+ def _check_margin(self):
+ for product in self:
+ if product.profit_margin < 0.0:
+ raise UserError(_("Percentages for Profit Margin must > 0."))
+
+
class BeesdooProduct(models.Model):
_inherit = "product.template"
@@ -252,12 +265,17 @@ class BeesdooProduct(models.Model):
for product in self:
suppliers = product._get_main_supplier_info()
if len(suppliers) > 0:
- product.suggested_price = (
- suppliers[0].price * product.uom_po_id.factor
- ) * (
- 1
- + suppliers[0].product_tmpl_id.categ_id.profit_margin / 100
+ price = suppliers[0].price
+ profit_margin_supplier = suppliers[0].name.profit_margin
+ profit_margin_product_category = suppliers[
+ 0
+ ].product_tmpl_id.categ_id.profit_margin
+ profit_margin = (
+ profit_margin_supplier or profit_margin_product_category
)
+ product.suggested_price = (
+ price * product.uom_po_id.factor
+ ) * (1 + profit_margin / 100)
class BeesdooScaleCategory(models.Model):
diff --git a/beesdoo_product/readme/DESCRIPTION.rst b/beesdoo_product/readme/DESCRIPTION.rst
index 7c3cfa8..297e02a 100644
--- a/beesdoo_product/readme/DESCRIPTION.rst
+++ b/beesdoo_product/readme/DESCRIPTION.rst
@@ -1,2 +1,3 @@
Modification of product module for the needs of beescoop
-- SOOO5 - Ajout de label bio/ethique/provenance
+- SOOO5 - Adds the label bio/ethique/provenance
+- Add a 'Suggested exVAT Price' field on products, and a 'Product Margin' field on Partners (Vendors) and Product Categories. The first margin is used if set, otherwise the second margin (which has a default value) is used.
diff --git a/beesdoo_product/views/beesdoo_product.xml b/beesdoo_product/views/beesdoo_product.xml
index f862c11..8083cb1 100644
--- a/beesdoo_product/views/beesdoo_product.xml
+++ b/beesdoo_product/views/beesdoo_product.xml
@@ -164,6 +164,17 @@
+
+ res.partner.form
+ res.partner
+
+
+
+
+
+
+
+
beesdoo.scale.category.list
beesdoo.scale.category