From 529e56061bc6d19a99dc61867a8714b56dbf92d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?=
Date: Thu, 12 Jul 2012 15:51:36 +0200
Subject: [PATCH 01/80] [MRG] From last customers devs, tests and bugfix. Most
improvements are on: - Margin modules - picking dispatch (better
warehouse handling)) - grouping PO - Filter on stock delivers
from sales (lp:c2c-addons/6.1 rev 28.3.22)
---
product_standard_margin/__init__.py | 22 ++++
product_standard_margin/__openerp__.py | 58 ++++++++++
product_standard_margin/product_std_margin.py | 106 ++++++++++++++++++
.../product_std_margin_view.xml | 21 ++++
4 files changed, 207 insertions(+)
create mode 100644 product_standard_margin/__init__.py
create mode 100644 product_standard_margin/__openerp__.py
create mode 100644 product_standard_margin/product_std_margin.py
create mode 100644 product_standard_margin/product_std_margin_view.xml
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
new file mode 100644
index 000000000..4a754ba5d
--- /dev/null
+++ b/product_standard_margin/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import product_std_margin
+
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
new file mode 100644
index 000000000..d42d8ed97
--- /dev/null
+++ b/product_standard_margin/__openerp__.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+{'name' : 'Markup rate on product and sales',
+ 'version' : '1.0',
+ 'author' : 'Camptocamp',
+ 'maintainer': 'Camptocamp',
+ 'category': 'Sales Management',
+ 'complexity': "normal", # easy, normal, expert
+ 'depends' : ['product_get_cost_field', 'account'],
+ 'description': """
+ Add a field on the product form that compute the standard (or theorical) margin based on the
+ current values of sale and cost price present in the product form. We take care of taxe included
+ or excluded.
+
+ It will just compute it as follow : (Sale Price without tax - Cost Price) / Sale Price without tax
+
+ Remember that this module can be used in conjonction with product_cost_incl_bom to have the
+ cost price computed from the BOM when a product has one.
+
+ WARNING:
+
+ 1) As this module will base his simple computation on sale and cost prices, it suppose
+ you have them both in the same currency (the price type must of the same currency for both of
+ them). Remember this is the default OpenERP configuration (price type of all product price
+ fields are set as the same as the company currency). We don't take care of it cause otherwise
+ we should have added a dependency on sale module.
+
+
+ """,
+ 'website': 'http://www.camptocamp.com/',
+ 'init_xml': [],
+ 'update_xml': ['product_std_margin_view.xml'],
+ 'demo_xml': [],
+ 'tests': [],
+ 'installable': True,
+ 'auto_install': False,
+ 'license': 'AGPL-3',
+ 'application': True}
+
+
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
new file mode 100644
index 000000000..43759d1fa
--- /dev/null
+++ b/product_standard_margin/product_std_margin.py
@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2012 Camptocamp SA (http://www.camptocamp.com)
+# All Right Reserved
+#
+# Author : Joel Grand-Guillaume
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from osv import fields
+from osv.orm import Model
+import decimal_precision as dp
+import logging
+
+class Product(Model):
+ _inherit = 'product.product'
+
+ #TODO : compute the margin with default taxes
+ def _amount_tax_excluded(self, cr, uid, ids, context=None):
+ """
+ Compute the list price total without tax (in case you are in tax included).
+ This will use the default taxes defined on the product.
+ :return dict of values:
+ {INT Product ID:
+ float price without tax
+ }
+ """
+ res = {}
+ if context is None:
+ context = {}
+ tax_obj = self.pool.get('account.tax')
+ cur_obj = self.pool.get('res.currency')
+ for prod in self.browse(cr, uid, ids):
+ price = prod.list_price
+ taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
+ res[prod.id] = taxes['total']
+ return res
+
+ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
+ """
+ Calculate the margin based on product infos. Take care of the cost_field
+ define in product_get_cost_field. So the margin will be computed based on this
+ field.
+
+ We don't take care of the product price type currency to remove the dependency on
+ the sale module. We consider the cost and sale price is in the company currency.
+
+ We take care of the default product taxes, and base our computation on total without
+ tax.
+
+ :return dict of dict of the form :
+ {INT Product ID : {
+ {'margin_absolute': float,
+ 'margin_relative': float}
+ }}
+ """
+ logger = logging.getLogger('product_standard_margin')
+ if context is None:
+ context = {}
+ res = {}
+ if not ids:
+ return res
+ for product in ids:
+ res[product] = {'margin_absolute': 0, 'margin_relative': 0}
+ for product in self.browse(cursor, user, ids):
+ cost = product.cost_price
+ sale = self._amount_tax_excluded(cursor, user, [product.id], context=context)[product.id]
+ # sale = product.list_price
+ res[product.id]['standard_margin'] = sale - cost
+ if sale == 0:
+ logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
+ res[product.id]['standard_margin_rate'] = 999.
+ else:
+ res[product.id]['standard_margin_rate'] = (sale - cost) / sale * 100
+ return res
+
+ _columns = {
+ 'standard_margin' : fields.function(_compute_margin,
+ method=True,
+ string='Theorical Margin',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi ='margin',
+ help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
+ 'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
+ 'standard_margin_rate' : fields.function(_compute_margin,
+ method=True,
+ string='Theorical Margin (%)',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
+ 'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
+ }
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
new file mode 100644
index 000000000..4ee497e4d
--- /dev/null
+++ b/product_standard_margin/product_std_margin_view.xml
@@ -0,0 +1,21 @@
+
+
+
+
+ product.markup.view.form
+ form
+ product.product
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 741b009ebc8b87d600cc2e47003c844223662680 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?=
Date: Fri, 29 Jun 2012 09:27:40 +0200
Subject: [PATCH 02/80] To ease merging the work with Alex, I already commit
part of work: [DOC] Some typo and docstring [IMP] Warning
message if no move available for dispatch creation [IMP] Start
adding relation between picking and dispatch (lp:c2c-addons/6.1 rev 28.6.4)
---
product_standard_margin/__init__.py | 22 ----
product_standard_margin/__openerp__.py | 58 ----------
product_standard_margin/product_std_margin.py | 106 ------------------
.../product_std_margin_view.xml | 21 ----
4 files changed, 207 deletions(-)
delete mode 100644 product_standard_margin/__init__.py
delete mode 100644 product_standard_margin/__openerp__.py
delete mode 100644 product_standard_margin/product_std_margin.py
delete mode 100644 product_standard_margin/product_std_margin_view.xml
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
deleted file mode 100644
index 4a754ba5d..000000000
--- a/product_standard_margin/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-from . import product_std_margin
-
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
deleted file mode 100644
index d42d8ed97..000000000
--- a/product_standard_margin/__openerp__.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-{'name' : 'Markup rate on product and sales',
- 'version' : '1.0',
- 'author' : 'Camptocamp',
- 'maintainer': 'Camptocamp',
- 'category': 'Sales Management',
- 'complexity': "normal", # easy, normal, expert
- 'depends' : ['product_get_cost_field', 'account'],
- 'description': """
- Add a field on the product form that compute the standard (or theorical) margin based on the
- current values of sale and cost price present in the product form. We take care of taxe included
- or excluded.
-
- It will just compute it as follow : (Sale Price without tax - Cost Price) / Sale Price without tax
-
- Remember that this module can be used in conjonction with product_cost_incl_bom to have the
- cost price computed from the BOM when a product has one.
-
- WARNING:
-
- 1) As this module will base his simple computation on sale and cost prices, it suppose
- you have them both in the same currency (the price type must of the same currency for both of
- them). Remember this is the default OpenERP configuration (price type of all product price
- fields are set as the same as the company currency). We don't take care of it cause otherwise
- we should have added a dependency on sale module.
-
-
- """,
- 'website': 'http://www.camptocamp.com/',
- 'init_xml': [],
- 'update_xml': ['product_std_margin_view.xml'],
- 'demo_xml': [],
- 'tests': [],
- 'installable': True,
- 'auto_install': False,
- 'license': 'AGPL-3',
- 'application': True}
-
-
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
deleted file mode 100644
index 43759d1fa..000000000
--- a/product_standard_margin/product_std_margin.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2012 Camptocamp SA (http://www.camptocamp.com)
-# All Right Reserved
-#
-# Author : Joel Grand-Guillaume
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from osv import fields
-from osv.orm import Model
-import decimal_precision as dp
-import logging
-
-class Product(Model):
- _inherit = 'product.product'
-
- #TODO : compute the margin with default taxes
- def _amount_tax_excluded(self, cr, uid, ids, context=None):
- """
- Compute the list price total without tax (in case you are in tax included).
- This will use the default taxes defined on the product.
- :return dict of values:
- {INT Product ID:
- float price without tax
- }
- """
- res = {}
- if context is None:
- context = {}
- tax_obj = self.pool.get('account.tax')
- cur_obj = self.pool.get('res.currency')
- for prod in self.browse(cr, uid, ids):
- price = prod.list_price
- taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
- res[prod.id] = taxes['total']
- return res
-
- def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
- """
- Calculate the margin based on product infos. Take care of the cost_field
- define in product_get_cost_field. So the margin will be computed based on this
- field.
-
- We don't take care of the product price type currency to remove the dependency on
- the sale module. We consider the cost and sale price is in the company currency.
-
- We take care of the default product taxes, and base our computation on total without
- tax.
-
- :return dict of dict of the form :
- {INT Product ID : {
- {'margin_absolute': float,
- 'margin_relative': float}
- }}
- """
- logger = logging.getLogger('product_standard_margin')
- if context is None:
- context = {}
- res = {}
- if not ids:
- return res
- for product in ids:
- res[product] = {'margin_absolute': 0, 'margin_relative': 0}
- for product in self.browse(cursor, user, ids):
- cost = product.cost_price
- sale = self._amount_tax_excluded(cursor, user, [product.id], context=context)[product.id]
- # sale = product.list_price
- res[product.id]['standard_margin'] = sale - cost
- if sale == 0:
- logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
- res[product.id]['standard_margin_rate'] = 999.
- else:
- res[product.id]['standard_margin_rate'] = (sale - cost) / sale * 100
- return res
-
- _columns = {
- 'standard_margin' : fields.function(_compute_margin,
- method=True,
- string='Theorical Margin',
- digits_compute=dp.get_precision('Sale Price'),
- multi ='margin',
- help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
- 'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
- 'standard_margin_rate' : fields.function(_compute_margin,
- method=True,
- string='Theorical Margin (%)',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
- 'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
- }
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
deleted file mode 100644
index 4ee497e4d..000000000
--- a/product_standard_margin/product_std_margin_view.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
- product.markup.view.form
- form
- product.product
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From 08ed05c92ff9cc5cd40959bbd001c621b26d2015 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?=
Date: Wed, 11 Jul 2012 17:13:42 +0200
Subject: [PATCH 03/80] [IMP] Rebuild the margin modules. This is the first
working version that still need strong testing (lp:c2c-addons/6.1 rev
28.6.24)
---
product_standard_margin/__init__.py | 22 +++++
product_standard_margin/__openerp__.py | 58 +++++++++++++
product_standard_margin/product_std_margin.py | 84 +++++++++++++++++++
.../product_std_margin_view.xml | 21 +++++
4 files changed, 185 insertions(+)
create mode 100644 product_standard_margin/__init__.py
create mode 100644 product_standard_margin/__openerp__.py
create mode 100644 product_standard_margin/product_std_margin.py
create mode 100644 product_standard_margin/product_std_margin_view.xml
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
new file mode 100644
index 000000000..4a754ba5d
--- /dev/null
+++ b/product_standard_margin/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import product_std_margin
+
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
new file mode 100644
index 000000000..6640d0692
--- /dev/null
+++ b/product_standard_margin/__openerp__.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+{'name' : 'Markup rate on product and sales',
+ 'version' : '1.0',
+ 'author' : 'Camptocamp',
+ 'maintainer': 'Camptocamp',
+ 'category': 'Sales Management',
+ 'complexity': "normal", # easy, normal, expert
+ 'depends' : ['product_get_cost_field',],
+ 'description': """
+ Add a field on the product form that compute the standard (or theorical) margin based on the
+ current values of sale and cost price present in the product form.
+
+ It will just compute it as follow : (Sale Price - Cost Price) / Sale Price
+
+ Remember that this module can be used in conjonction with product_cost_incl_bom to have the
+ cost price computed from the BOM when a product has one.
+
+ WARNING:
+
+ 1) As this module will base his simple computation on sale and cost prices, it suppose
+ you have them both in the same currency (the price type must of the same currency for both of
+ them). Remember this is the default OpenERP configuration (price type of all product price
+ fields are set as the same as the company currency). We don't take care of it cause otherwise
+ we should have added a dependency on sale module.
+
+ 2) For now we consider always the prices values are VAT excluded
+
+ """,
+ 'website': 'http://www.camptocamp.com/',
+ 'init_xml': [],
+ 'update_xml': ['product_std_margin_view.xml'],
+ 'demo_xml': [],
+ 'tests': [],
+ 'installable': True,
+ 'auto_install': False,
+ 'license': 'AGPL-3',
+ 'application': True}
+
+
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
new file mode 100644
index 000000000..b2ac8c43c
--- /dev/null
+++ b/product_standard_margin/product_std_margin.py
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2012 Camptocamp SA (http://www.camptocamp.com)
+# All Right Reserved
+#
+# Author : Joel Grand-Guillaume
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from osv import fields
+from osv.orm import Model
+import decimal_precision as dp
+import logging
+
+class Product(Model):
+ _inherit = 'product.product'
+
+ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
+ """
+ Calculate the margin based on product infos. Take care of the cost_field
+ define in product_get_cost_field. So the margin will be computed based on this
+ field.
+
+ We don't take care of the product price type currency to remove the dependency on
+ the sale module. We consider the cost and sale price is in the company currency.
+
+ We don't take care of the taxes, and base our computation on the hypothesis that
+ all prices are VAT excluded.
+
+ :return dict of dict of the form :
+ {INT Product ID : {
+ {'margin_absolute': float,
+ 'margin_relative': float}
+ }}
+ """
+ logger = logging.getLogger('product_standard_margin')
+ if context is None:
+ context = {}
+ res = {}
+ if not ids:
+ return res
+ for product in ids:
+ res[product] = {'margin_absolute': 0, 'margin_relative': 0}
+ for product in self.browse(cursor, user, ids):
+ cost = product.cost_price
+ sale = product.list_price
+ res[product.id]['standard_margin'] = sale - cost
+ if sale == 0:
+ logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
+ res[product.id]['standard_margin_rate'] = 999.
+ else:
+ res[product.id]['standard_margin_rate'] = (sale - cost) / sale * 100
+ return res
+
+ _columns = {
+ 'standard_margin' : fields.function(_compute_margin,
+ method=True,
+ string='Theorical Margin',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi ='margin',
+ help='Theorical Margin is [ sale price - cost price ] of the product form (not based on historical values).'
+ 'Prices should be VAT excluded. If no sale price, the margin will be negativ.'),
+ 'standard_margin_rate' : fields.function(_compute_margin,
+ method=True,
+ string='Theorical Margin (%)',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Markup rate is [ Theorical Margin / sale price ] of the product form (not based on historical values).'
+ 'Prices should be VAT excluded. If no sale price set, will display 999.0'),
+ }
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
new file mode 100644
index 000000000..4ee497e4d
--- /dev/null
+++ b/product_standard_margin/product_std_margin_view.xml
@@ -0,0 +1,21 @@
+
+
+
+
+ product.markup.view.form
+ form
+ product.product
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 8d30020e812b4b48ed0a4d5c7640607e28a4986a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?=
Date: Thu, 12 Jul 2012 09:45:48 +0200
Subject: [PATCH 04/80] [ADD] product_historical_margin_report that override
the invoice line analysis to add margin [IMP] Add tax
include/exlude support on margin computation [FIX] Little Typo and
fixes after tests (lp:c2c-addons/6.1 rev 28.6.25)
---
product_standard_margin/__openerp__.py | 8 ++---
product_standard_margin/product_std_margin.py | 36 +++++++++++++++----
2 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index 6640d0692..d42d8ed97 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -24,12 +24,13 @@
'maintainer': 'Camptocamp',
'category': 'Sales Management',
'complexity': "normal", # easy, normal, expert
- 'depends' : ['product_get_cost_field',],
+ 'depends' : ['product_get_cost_field', 'account'],
'description': """
Add a field on the product form that compute the standard (or theorical) margin based on the
- current values of sale and cost price present in the product form.
+ current values of sale and cost price present in the product form. We take care of taxe included
+ or excluded.
- It will just compute it as follow : (Sale Price - Cost Price) / Sale Price
+ It will just compute it as follow : (Sale Price without tax - Cost Price) / Sale Price without tax
Remember that this module can be used in conjonction with product_cost_incl_bom to have the
cost price computed from the BOM when a product has one.
@@ -42,7 +43,6 @@
fields are set as the same as the company currency). We don't take care of it cause otherwise
we should have added a dependency on sale module.
- 2) For now we consider always the prices values are VAT excluded
""",
'website': 'http://www.camptocamp.com/',
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index b2ac8c43c..43759d1fa 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -29,6 +29,27 @@
class Product(Model):
_inherit = 'product.product'
+ #TODO : compute the margin with default taxes
+ def _amount_tax_excluded(self, cr, uid, ids, context=None):
+ """
+ Compute the list price total without tax (in case you are in tax included).
+ This will use the default taxes defined on the product.
+ :return dict of values:
+ {INT Product ID:
+ float price without tax
+ }
+ """
+ res = {}
+ if context is None:
+ context = {}
+ tax_obj = self.pool.get('account.tax')
+ cur_obj = self.pool.get('res.currency')
+ for prod in self.browse(cr, uid, ids):
+ price = prod.list_price
+ taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
+ res[prod.id] = taxes['total']
+ return res
+
def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
"""
Calculate the margin based on product infos. Take care of the cost_field
@@ -38,8 +59,8 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
We don't take care of the product price type currency to remove the dependency on
the sale module. We consider the cost and sale price is in the company currency.
- We don't take care of the taxes, and base our computation on the hypothesis that
- all prices are VAT excluded.
+ We take care of the default product taxes, and base our computation on total without
+ tax.
:return dict of dict of the form :
{INT Product ID : {
@@ -57,7 +78,8 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
res[product] = {'margin_absolute': 0, 'margin_relative': 0}
for product in self.browse(cursor, user, ids):
cost = product.cost_price
- sale = product.list_price
+ sale = self._amount_tax_excluded(cursor, user, [product.id], context=context)[product.id]
+ # sale = product.list_price
res[product.id]['standard_margin'] = sale - cost
if sale == 0:
logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
@@ -72,13 +94,13 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
string='Theorical Margin',
digits_compute=dp.get_precision('Sale Price'),
multi ='margin',
- help='Theorical Margin is [ sale price - cost price ] of the product form (not based on historical values).'
- 'Prices should be VAT excluded. If no sale price, the margin will be negativ.'),
+ help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
+ 'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
'standard_margin_rate' : fields.function(_compute_margin,
method=True,
string='Theorical Margin (%)',
digits_compute=dp.get_precision('Sale Price'),
multi='margin',
- help='Markup rate is [ Theorical Margin / sale price ] of the product form (not based on historical values).'
- 'Prices should be VAT excluded. If no sale price set, will display 999.0'),
+ help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
+ 'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
}
From 6002698c12077d238700e7cdbffcd65076b6a04d Mon Sep 17 00:00:00 2001
From: "@" <@>
Date: Tue, 15 May 2012 14:42:21 +0200
Subject: [PATCH 05/80] [IMP] product_cost_incl_bom, product_get_cost_field,
sale_markup: extracted code to new modules
extracted the bits about the computation of product cost with BoM from sale_markup to product_cost_incl_bom
(lp:c2c-addons/6.1 rev 40.1.13)
---
product_standard_margin/__init__.py | 22 ----
product_standard_margin/__openerp__.py | 58 ----------
product_standard_margin/product_std_margin.py | 106 ------------------
.../product_std_margin_view.xml | 21 ----
4 files changed, 207 deletions(-)
delete mode 100644 product_standard_margin/__init__.py
delete mode 100644 product_standard_margin/__openerp__.py
delete mode 100644 product_standard_margin/product_std_margin.py
delete mode 100644 product_standard_margin/product_std_margin_view.xml
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
deleted file mode 100644
index 4a754ba5d..000000000
--- a/product_standard_margin/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-from . import product_std_margin
-
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
deleted file mode 100644
index d42d8ed97..000000000
--- a/product_standard_margin/__openerp__.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-{'name' : 'Markup rate on product and sales',
- 'version' : '1.0',
- 'author' : 'Camptocamp',
- 'maintainer': 'Camptocamp',
- 'category': 'Sales Management',
- 'complexity': "normal", # easy, normal, expert
- 'depends' : ['product_get_cost_field', 'account'],
- 'description': """
- Add a field on the product form that compute the standard (or theorical) margin based on the
- current values of sale and cost price present in the product form. We take care of taxe included
- or excluded.
-
- It will just compute it as follow : (Sale Price without tax - Cost Price) / Sale Price without tax
-
- Remember that this module can be used in conjonction with product_cost_incl_bom to have the
- cost price computed from the BOM when a product has one.
-
- WARNING:
-
- 1) As this module will base his simple computation on sale and cost prices, it suppose
- you have them both in the same currency (the price type must of the same currency for both of
- them). Remember this is the default OpenERP configuration (price type of all product price
- fields are set as the same as the company currency). We don't take care of it cause otherwise
- we should have added a dependency on sale module.
-
-
- """,
- 'website': 'http://www.camptocamp.com/',
- 'init_xml': [],
- 'update_xml': ['product_std_margin_view.xml'],
- 'demo_xml': [],
- 'tests': [],
- 'installable': True,
- 'auto_install': False,
- 'license': 'AGPL-3',
- 'application': True}
-
-
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
deleted file mode 100644
index 43759d1fa..000000000
--- a/product_standard_margin/product_std_margin.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2012 Camptocamp SA (http://www.camptocamp.com)
-# All Right Reserved
-#
-# Author : Joel Grand-Guillaume
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from osv import fields
-from osv.orm import Model
-import decimal_precision as dp
-import logging
-
-class Product(Model):
- _inherit = 'product.product'
-
- #TODO : compute the margin with default taxes
- def _amount_tax_excluded(self, cr, uid, ids, context=None):
- """
- Compute the list price total without tax (in case you are in tax included).
- This will use the default taxes defined on the product.
- :return dict of values:
- {INT Product ID:
- float price without tax
- }
- """
- res = {}
- if context is None:
- context = {}
- tax_obj = self.pool.get('account.tax')
- cur_obj = self.pool.get('res.currency')
- for prod in self.browse(cr, uid, ids):
- price = prod.list_price
- taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
- res[prod.id] = taxes['total']
- return res
-
- def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
- """
- Calculate the margin based on product infos. Take care of the cost_field
- define in product_get_cost_field. So the margin will be computed based on this
- field.
-
- We don't take care of the product price type currency to remove the dependency on
- the sale module. We consider the cost and sale price is in the company currency.
-
- We take care of the default product taxes, and base our computation on total without
- tax.
-
- :return dict of dict of the form :
- {INT Product ID : {
- {'margin_absolute': float,
- 'margin_relative': float}
- }}
- """
- logger = logging.getLogger('product_standard_margin')
- if context is None:
- context = {}
- res = {}
- if not ids:
- return res
- for product in ids:
- res[product] = {'margin_absolute': 0, 'margin_relative': 0}
- for product in self.browse(cursor, user, ids):
- cost = product.cost_price
- sale = self._amount_tax_excluded(cursor, user, [product.id], context=context)[product.id]
- # sale = product.list_price
- res[product.id]['standard_margin'] = sale - cost
- if sale == 0:
- logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
- res[product.id]['standard_margin_rate'] = 999.
- else:
- res[product.id]['standard_margin_rate'] = (sale - cost) / sale * 100
- return res
-
- _columns = {
- 'standard_margin' : fields.function(_compute_margin,
- method=True,
- string='Theorical Margin',
- digits_compute=dp.get_precision('Sale Price'),
- multi ='margin',
- help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
- 'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
- 'standard_margin_rate' : fields.function(_compute_margin,
- method=True,
- string='Theorical Margin (%)',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
- 'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
- }
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
deleted file mode 100644
index 4ee497e4d..000000000
--- a/product_standard_margin/product_std_margin_view.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
- product.markup.view.form
- form
- product.product
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From b9f9d10ac1d0f2118b03efb6f57b9ea2eca6e4b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=ABl=20Grand-Guillaume?=
Date: Thu, 12 Jul 2012 15:56:17 +0200
Subject: [PATCH 06/80] [MRG] From trunk branch, tests and bugfix. Most
improvements are on: - Margin modules - picking dispatch (better
warehouse handling)) - grouping PO - Filter on stock delivers from sales
(lp:c2c-addons/6.1 rev 69)
---
product_standard_margin/__init__.py | 22 ++++
product_standard_margin/__openerp__.py | 58 ++++++++++
product_standard_margin/product_std_margin.py | 106 ++++++++++++++++++
.../product_std_margin_view.xml | 21 ++++
4 files changed, 207 insertions(+)
create mode 100644 product_standard_margin/__init__.py
create mode 100644 product_standard_margin/__openerp__.py
create mode 100644 product_standard_margin/product_std_margin.py
create mode 100644 product_standard_margin/product_std_margin_view.xml
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
new file mode 100644
index 000000000..4a754ba5d
--- /dev/null
+++ b/product_standard_margin/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import product_std_margin
+
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
new file mode 100644
index 000000000..d42d8ed97
--- /dev/null
+++ b/product_standard_margin/__openerp__.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+{'name' : 'Markup rate on product and sales',
+ 'version' : '1.0',
+ 'author' : 'Camptocamp',
+ 'maintainer': 'Camptocamp',
+ 'category': 'Sales Management',
+ 'complexity': "normal", # easy, normal, expert
+ 'depends' : ['product_get_cost_field', 'account'],
+ 'description': """
+ Add a field on the product form that compute the standard (or theorical) margin based on the
+ current values of sale and cost price present in the product form. We take care of taxe included
+ or excluded.
+
+ It will just compute it as follow : (Sale Price without tax - Cost Price) / Sale Price without tax
+
+ Remember that this module can be used in conjonction with product_cost_incl_bom to have the
+ cost price computed from the BOM when a product has one.
+
+ WARNING:
+
+ 1) As this module will base his simple computation on sale and cost prices, it suppose
+ you have them both in the same currency (the price type must of the same currency for both of
+ them). Remember this is the default OpenERP configuration (price type of all product price
+ fields are set as the same as the company currency). We don't take care of it cause otherwise
+ we should have added a dependency on sale module.
+
+
+ """,
+ 'website': 'http://www.camptocamp.com/',
+ 'init_xml': [],
+ 'update_xml': ['product_std_margin_view.xml'],
+ 'demo_xml': [],
+ 'tests': [],
+ 'installable': True,
+ 'auto_install': False,
+ 'license': 'AGPL-3',
+ 'application': True}
+
+
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
new file mode 100644
index 000000000..43759d1fa
--- /dev/null
+++ b/product_standard_margin/product_std_margin.py
@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2012 Camptocamp SA (http://www.camptocamp.com)
+# All Right Reserved
+#
+# Author : Joel Grand-Guillaume
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from osv import fields
+from osv.orm import Model
+import decimal_precision as dp
+import logging
+
+class Product(Model):
+ _inherit = 'product.product'
+
+ #TODO : compute the margin with default taxes
+ def _amount_tax_excluded(self, cr, uid, ids, context=None):
+ """
+ Compute the list price total without tax (in case you are in tax included).
+ This will use the default taxes defined on the product.
+ :return dict of values:
+ {INT Product ID:
+ float price without tax
+ }
+ """
+ res = {}
+ if context is None:
+ context = {}
+ tax_obj = self.pool.get('account.tax')
+ cur_obj = self.pool.get('res.currency')
+ for prod in self.browse(cr, uid, ids):
+ price = prod.list_price
+ taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
+ res[prod.id] = taxes['total']
+ return res
+
+ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
+ """
+ Calculate the margin based on product infos. Take care of the cost_field
+ define in product_get_cost_field. So the margin will be computed based on this
+ field.
+
+ We don't take care of the product price type currency to remove the dependency on
+ the sale module. We consider the cost and sale price is in the company currency.
+
+ We take care of the default product taxes, and base our computation on total without
+ tax.
+
+ :return dict of dict of the form :
+ {INT Product ID : {
+ {'margin_absolute': float,
+ 'margin_relative': float}
+ }}
+ """
+ logger = logging.getLogger('product_standard_margin')
+ if context is None:
+ context = {}
+ res = {}
+ if not ids:
+ return res
+ for product in ids:
+ res[product] = {'margin_absolute': 0, 'margin_relative': 0}
+ for product in self.browse(cursor, user, ids):
+ cost = product.cost_price
+ sale = self._amount_tax_excluded(cursor, user, [product.id], context=context)[product.id]
+ # sale = product.list_price
+ res[product.id]['standard_margin'] = sale - cost
+ if sale == 0:
+ logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
+ res[product.id]['standard_margin_rate'] = 999.
+ else:
+ res[product.id]['standard_margin_rate'] = (sale - cost) / sale * 100
+ return res
+
+ _columns = {
+ 'standard_margin' : fields.function(_compute_margin,
+ method=True,
+ string='Theorical Margin',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi ='margin',
+ help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
+ 'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
+ 'standard_margin_rate' : fields.function(_compute_margin,
+ method=True,
+ string='Theorical Margin (%)',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
+ 'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
+ }
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
new file mode 100644
index 000000000..4ee497e4d
--- /dev/null
+++ b/product_standard_margin/product_std_margin_view.xml
@@ -0,0 +1,21 @@
+
+
+
+
+ product.markup.view.form
+ form
+ product.product
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 931762a9cb95f99e8fd4133219e6da3bbb6f5a09 Mon Sep 17 00:00:00 2001
From: unknown
Date: Thu, 13 Dec 2012 13:39:06 +0100
Subject: [PATCH 07/80] [ADD] translation FR on product_standard_margin and
product_historical_margin
---
product_standard_margin/i18n/fr.po | 52 ++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
create mode 100644 product_standard_margin/i18n/fr.po
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
new file mode 100644
index 000000000..b1c3d392b
--- /dev/null
+++ b/product_standard_margin/i18n/fr.po
@@ -0,0 +1,52 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-11-07 14:35+0000\n"
+"PO-Revision-Date: 2012-11-07 14:35+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr "Produit"
+
+#. module: product_standard_margin
+#: field:product.product,standard_margin_rate:0
+msgid "Theorical Margin (%)"
+msgstr "Marge Theorique (%)"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin_rate:0
+msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr "Taux de marge théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du formulaire Produit] (ne tient pas compte de la facturation effective). Ce taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le taux sera de 999.0"
+
+#. module: product_standard_margin
+#: constraint:product.product:0
+msgid "Error: Invalid ean code"
+msgstr "Erreur : Code EAN invalide"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin:0
+msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgstr "Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient pas compte de la facturation effective).Ce taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, la marge sera negative."
+
+#. module: product_standard_margin
+#: view:product.product:0
+msgid "Margin"
+msgstr "Marge"
+
+#. module: product_standard_margin
+#: field:product.product,standard_margin:0
+msgid "Theorical Margin"
+msgstr "Marge Théorique"
+
From be5bfaba1acb2c800f25e57de808127176c880d6 Mon Sep 17 00:00:00 2001
From: "@" <@>
Date: Thu, 13 Dec 2012 15:19:45 +0100
Subject: [PATCH 08/80] [FIX] typos
---
product_standard_margin/i18n/fr.po | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
index b1c3d392b..1c99776a8 100644
--- a/product_standard_margin/i18n/fr.po
+++ b/product_standard_margin/i18n/fr.po
@@ -23,7 +23,7 @@ msgstr "Produit"
#. module: product_standard_margin
#: field:product.product,standard_margin_rate:0
msgid "Theorical Margin (%)"
-msgstr "Marge Theorique (%)"
+msgstr "Marge Théorique (%)"
#. module: product_standard_margin
#: help:product.product,standard_margin_rate:0
@@ -38,7 +38,7 @@ msgstr "Erreur : Code EAN invalide"
#. module: product_standard_margin
#: help:product.product,standard_margin:0
msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).Take care of tax include and exclude. If no sale price, the margin will be negativ."
-msgstr "Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient pas compte de la facturation effective).Ce taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, la marge sera negative."
+msgstr "Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient pas compte de la facturation effective). Ce taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, la marge sera négative."
#. module: product_standard_margin
#: view:product.product:0
From a0ef06859fb8e73b47763a104b0412e1bdf7b6ce Mon Sep 17 00:00:00 2001
From: Endian Solutions
Date: Sun, 23 Dec 2012 13:12:06 +0100
Subject: [PATCH 09/80] Added Dutch translations to all modules.
---
product_standard_margin/i18n/nl.po | 67 ++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
create mode 100644 product_standard_margin/i18n/nl.po
diff --git a/product_standard_margin/i18n/nl.po b/product_standard_margin/i18n/nl.po
new file mode 100644
index 000000000..2df248f7a
--- /dev/null
+++ b/product_standard_margin/i18n/nl.po
@@ -0,0 +1,67 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-12-23 12:04+0000\n"
+"PO-Revision-Date: 2012-12-23 13:09+0100\n"
+"Last-Translator: Erwin van der Ploeg | Endian Solutions "
+"\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+"X-Generator: Poedit 1.5.4\n"
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr "Product"
+
+#. module: product_standard_margin
+#: field:product.product,standard_margin_rate:0
+msgid "Theorical Margin (%)"
+msgstr "Theoretische marge (%)"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin_rate:0
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+"Theoretische marge (%) is [ Theoretische marge / Verkoopprijs (excl. BTW) ] "
+"van het product (niet gebaseerd op historische waardes). Het veld houdt "
+"rekening met prijzen incl. en excl. BTW. Indien geen verkooprijs is "
+"ingevoerd, wordt 999,0 weergegeven."
+
+#. module: product_standard_margin
+#: constraint:product.product:0
+msgid "Error: Invalid ean code"
+msgstr "Fout: ongeldige ean code"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin:0
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values).Take care of tax include and exclude. If no "
+"sale price, the margin will be negativ."
+msgstr ""
+"Theoretische marge is [ Verkoopprijs (excl. BTW) - Kostprijs) ] van het "
+"product (niet gebaseerd op historische waardes). Het veld houdt rekening met "
+"prijzen incl. en excl. BTW. Indien geen verkooprijs is ingevoerd, zal de "
+"marge negatief zijn."
+
+#. module: product_standard_margin
+#: view:product.product:0
+msgid "Margin"
+msgstr "Marge"
+
+#. module: product_standard_margin
+#: field:product.product,standard_margin:0
+msgid "Theorical Margin"
+msgstr "Theorische marge"
From a54371f00c0a7ff31dc6dd61a451a135807fcf55 Mon Sep 17 00:00:00 2001
From: Endian Solutions
Date: Sun, 23 Dec 2012 13:48:18 +0100
Subject: [PATCH 10/80] small fix in translation
---
product_standard_margin/i18n/nl.po | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/product_standard_margin/i18n/nl.po b/product_standard_margin/i18n/nl.po
index 2df248f7a..554bdeb5a 100644
--- a/product_standard_margin/i18n/nl.po
+++ b/product_standard_margin/i18n/nl.po
@@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-12-23 12:04+0000\n"
-"PO-Revision-Date: 2012-12-23 13:09+0100\n"
+"PO-Revision-Date: 2012-12-23 13:35+0100\n"
"Last-Translator: Erwin van der Ploeg | Endian Solutions "
"\n"
"Language-Team: \n"
@@ -64,4 +64,4 @@ msgstr "Marge"
#. module: product_standard_margin
#: field:product.product,standard_margin:0
msgid "Theorical Margin"
-msgstr "Theorische marge"
+msgstr "Theoretische marge"
From 135419ac5d8815938cd146ae731001682ea8c1e6 Mon Sep 17 00:00:00 2001
From: Joel Grand-Guillaume
Date: Wed, 11 Sep 2013 10:08:22 +0200
Subject: [PATCH 11/80] [MIGR] Mark all module as installable = False unless we
migrate them. This will happend in the next coming month.
---
product_standard_margin/__openerp__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index d42d8ed97..5b1f4d407 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -50,7 +50,7 @@
'update_xml': ['product_std_margin_view.xml'],
'demo_xml': [],
'tests': [],
- 'installable': True,
+ 'installable': False,
'auto_install': False,
'license': 'AGPL-3',
'application': True}
From 175275955f3ea6d2ffb7fae6ca4377906dedc06f Mon Sep 17 00:00:00 2001
From: Yannick Vaucher
Date: Thu, 10 Oct 2013 14:09:34 +0200
Subject: [PATCH 12/80] [MIG] portage of product_standard_margin
---
product_standard_margin/__openerp__.py | 26 ++++++------
product_standard_margin/product_std_margin.py | 41 ++++++++++---------
.../product_std_margin_view.xml | 11 +++--
3 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index 5b1f4d407..c4b4c8718 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -18,39 +18,39 @@
# along with this program. If not, see .
#
##############################################################################
-{'name' : 'Markup rate on product and sales',
- 'version' : '1.0',
- 'author' : 'Camptocamp',
+{'name': 'Markup rate on product and sales',
+ 'version': '1.0',
+ 'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'category': 'Sales Management',
'complexity': "normal", # easy, normal, expert
- 'depends' : ['product_get_cost_field', 'account'],
+ 'depends': ['product_get_cost_field', 'account'],
'description': """
Add a field on the product form that compute the standard (or theorical) margin based on the
current values of sale and cost price present in the product form. We take care of taxe included
or excluded.
-
- It will just compute it as follow : (Sale Price without tax - Cost Price) / Sale Price without tax
-
+
+ It will just compute it as follow: (Sale Price without tax - Cost Price) / Sale Price without tax
+
Remember that this module can be used in conjonction with product_cost_incl_bom to have the
cost price computed from the BOM when a product has one.
-
- WARNING:
-
+
+ WARNING:
+
1) As this module will base his simple computation on sale and cost prices, it suppose
you have them both in the same currency (the price type must of the same currency for both of
them). Remember this is the default OpenERP configuration (price type of all product price
fields are set as the same as the company currency). We don't take care of it cause otherwise
we should have added a dependency on sale module.
-
-
+
+
""",
'website': 'http://www.camptocamp.com/',
'init_xml': [],
'update_xml': ['product_std_margin_view.xml'],
'demo_xml': [],
'tests': [],
- 'installable': False,
+ 'installable': True,
'auto_install': False,
'license': 'AGPL-3',
'application': True}
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index 43759d1fa..27ff7211e 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -28,7 +28,7 @@
class Product(Model):
_inherit = 'product.product'
-
+
#TODO : compute the margin with default taxes
def _amount_tax_excluded(self, cr, uid, ids, context=None):
"""
@@ -49,19 +49,19 @@ def _amount_tax_excluded(self, cr, uid, ids, context=None):
taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
res[prod.id] = taxes['total']
return res
-
+
def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
"""
Calculate the margin based on product infos. Take care of the cost_field
define in product_get_cost_field. So the margin will be computed based on this
field.
-
+
We don't take care of the product price type currency to remove the dependency on
the sale module. We consider the cost and sale price is in the company currency.
-
+
We take care of the default product taxes, and base our computation on total without
tax.
-
+
:return dict of dict of the form :
{INT Product ID : {
{'margin_absolute': float,
@@ -79,7 +79,6 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
for product in self.browse(cursor, user, ids):
cost = product.cost_price
sale = self._amount_tax_excluded(cursor, user, [product.id], context=context)[product.id]
- # sale = product.list_price
res[product.id]['standard_margin'] = sale - cost
if sale == 0:
logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
@@ -89,18 +88,20 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
return res
_columns = {
- 'standard_margin' : fields.function(_compute_margin,
- method=True,
- string='Theorical Margin',
- digits_compute=dp.get_precision('Sale Price'),
- multi ='margin',
- help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
- 'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
- 'standard_margin_rate' : fields.function(_compute_margin,
- method=True,
- string='Theorical Margin (%)',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
- 'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
+ 'standard_margin': fields.function(
+ _compute_margin,
+ method=True,
+ string='Theorical Margin',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi ='margin',
+ help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
+ 'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
+ 'standard_margin_rate': fields.function(
+ _compute_margin,
+ method=True,
+ string='Theorical Margin (%)',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
+ 'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
}
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
index 4ee497e4d..5fbd14c29 100644
--- a/product_standard_margin/product_std_margin_view.xml
+++ b/product_standard_margin/product_std_margin_view.xml
@@ -7,13 +7,12 @@
product.product
-
-
-
-
-
-
+
+
+
+
+
From 78030a52e42a3c21946398c23216fe5455adf3bf Mon Sep 17 00:00:00 2001
From: Yannick Vaucher
Date: Mon, 14 Oct 2013 20:08:34 +0200
Subject: [PATCH 13/80] [FIX] imports
---
product_standard_margin/product_std_margin.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index 27ff7211e..7f39ed31d 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -21,12 +21,12 @@
#
##############################################################################
-from osv import fields
-from osv.orm import Model
+from openerp.osv import orm, fields
import decimal_precision as dp
import logging
-class Product(Model):
+
+class Product(orm.Model):
_inherit = 'product.product'
#TODO : compute the margin with default taxes
From 65e7aa27849144602bdcc1d06607aee60efa37cb Mon Sep 17 00:00:00 2001
From: Yannick Vaucher
Date: Mon, 14 Oct 2013 20:16:46 +0200
Subject: [PATCH 14/80] [PEP8]
---
product_standard_margin/__openerp__.py | 9 ++---
product_standard_margin/product_std_margin.py | 40 ++++++++++---------
2 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index c4b4c8718..c901845f4 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -32,18 +32,17 @@
It will just compute it as follow: (Sale Price without tax - Cost Price) / Sale Price without tax
- Remember that this module can be used in conjonction with product_cost_incl_bom to have the
+ Remember that this module can be used in conjonction with product_cost_incl_bom to have the
cost price computed from the BOM when a product has one.
WARNING:
1) As this module will base his simple computation on sale and cost prices, it suppose
- you have them both in the same currency (the price type must of the same currency for both of
- them). Remember this is the default OpenERP configuration (price type of all product price
+ you have them both in the same currency (the price type must of the same currency for both of
+ them). Remember this is the default OpenERP configuration (price type of all product price
fields are set as the same as the company currency). We don't take care of it cause otherwise
we should have added a dependency on sale module.
-
""",
'website': 'http://www.camptocamp.com/',
'init_xml': [],
@@ -54,5 +53,3 @@
'auto_install': False,
'license': 'AGPL-3',
'application': True}
-
-
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index 7f39ed31d..fa97b668f 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -33,9 +33,9 @@ class Product(orm.Model):
def _amount_tax_excluded(self, cr, uid, ids, context=None):
"""
Compute the list price total without tax (in case you are in tax included).
- This will use the default taxes defined on the product.
+ This will use the default taxes defined on the product.
:return dict of values:
- {INT Product ID:
+ {INT Product ID:
float price without tax
}
"""
@@ -43,28 +43,27 @@ def _amount_tax_excluded(self, cr, uid, ids, context=None):
if context is None:
context = {}
tax_obj = self.pool.get('account.tax')
- cur_obj = self.pool.get('res.currency')
for prod in self.browse(cr, uid, ids):
price = prod.list_price
taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
res[prod.id] = taxes['total']
return res
- def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
+ def _compute_margin(self, cursor, user, ids, field_name, arg, context=None):
"""
- Calculate the margin based on product infos. Take care of the cost_field
- define in product_get_cost_field. So the margin will be computed based on this
+ Calculate the margin based on product infos. Take care of the cost_field
+ define in product_get_cost_field. So the margin will be computed based on this
field.
We don't take care of the product price type currency to remove the dependency on
the sale module. We consider the cost and sale price is in the company currency.
- We take care of the default product taxes, and base our computation on total without
+ We take care of the default product taxes, and base our computation on total without
tax.
- :return dict of dict of the form :
+ :return dict of dict of the form :
{INT Product ID : {
- {'margin_absolute': float,
+ {'margin_absolute': float,
'margin_relative': float}
}}
"""
@@ -78,7 +77,8 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
res[product] = {'margin_absolute': 0, 'margin_relative': 0}
for product in self.browse(cursor, user, ids):
cost = product.cost_price
- sale = self._amount_tax_excluded(cursor, user, [product.id], context=context)[product.id]
+ sale = self._amount_tax_excluded(cursor, user,
+ [product.id], context=context)[product.id]
res[product.id]['standard_margin'] = sale - cost
if sale == 0:
logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
@@ -90,18 +90,22 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
_columns = {
'standard_margin': fields.function(
_compute_margin,
- method=True,
- string='Theorical Margin',
- digits_compute=dp.get_precision('Sale Price'),
- multi ='margin',
- help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
- 'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
+ method=True,
+ string='Theorical Margin',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Theorical Margin is [ sale price (Wo Tax) - cost price ] '
+ 'of the product form (not based on historical values). '
+ 'Take care of tax include and exclude. If no sale price, '
+ 'the margin will be negativ.'),
'standard_margin_rate': fields.function(
_compute_margin,
method=True,
string='Theorical Margin (%)',
digits_compute=dp.get_precision('Sale Price'),
multi='margin',
- help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
- 'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
+ help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] '
+ 'of the product form (not based on historical values).'
+ 'Take care of tax include and exclude.. If no sale price '
+ 'set, will display 999.0'),
}
From e8ff61184c53843bb24b4b44fa7248a09d963f9c Mon Sep 17 00:00:00 2001
From: Yannick Vaucher
Date: Mon, 14 Oct 2013 20:19:31 +0200
Subject: [PATCH 15/80] [IMP] use date in __openerp__.py instead of deprecated
update_xml and demo_xml
---
product_standard_margin/__openerp__.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index c901845f4..d5f28959b 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -46,8 +46,7 @@
""",
'website': 'http://www.camptocamp.com/',
'init_xml': [],
- 'update_xml': ['product_std_margin_view.xml'],
- 'demo_xml': [],
+ 'data': ['product_std_margin_view.xml'],
'tests': [],
'installable': True,
'auto_install': False,
From c5ec87ee16e54f78b7f2e8509645fdc0b057083d Mon Sep 17 00:00:00 2001
From: Yannick Vaucher
Date: Mon, 14 Oct 2013 20:42:41 +0200
Subject: [PATCH 16/80] [FIX] remove group to show margin fields
---
product_standard_margin/product_std_margin_view.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
index 5fbd14c29..07cfa3135 100644
--- a/product_standard_margin/product_std_margin_view.xml
+++ b/product_standard_margin/product_std_margin_view.xml
@@ -7,8 +7,8 @@
product.product
-
-
+
+
From 188beacc60e6f5977e264205ba57cfba4aea16b1 Mon Sep 17 00:00:00 2001
From: Yannick Vaucher
Date: Mon, 14 Oct 2013 20:43:38 +0200
Subject: [PATCH 17/80] [ADD] pot file
---
.../i18n/product_standard_margin.pot | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 product_standard_margin/i18n/product_standard_margin.pot
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
new file mode 100644
index 000000000..264b76eda
--- /dev/null
+++ b/product_standard_margin/i18n/product_standard_margin.pot
@@ -0,0 +1,44 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-10-14 18:35+0000\n"
+"PO-Revision-Date: 2013-10-14 18:35+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin_rate:0
+msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin_rate
+#: field:product.product,standard_margin_rate:0
+msgid "Theorical Margin (%)"
+msgstr ""
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin:0
+msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin
+#: field:product.product,standard_margin:0
+msgid "Theorical Margin"
+msgstr ""
+
From ec3e9c15ef42be973b8d93e7d336ba74701cad28 Mon Sep 17 00:00:00 2001
From: Yannick Vaucher
Date: Mon, 14 Oct 2013 20:43:50 +0200
Subject: [PATCH 18/80] [IMP] update fr.po
---
product_standard_margin/i18n/fr.po | 47 +++++++++++++++++-------------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
index 1c99776a8..228f7994f 100644
--- a/product_standard_margin/i18n/fr.po
+++ b/product_standard_margin/i18n/fr.po
@@ -1,52 +1,57 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
-# * product_standard_margin
+# * product_standard_margin
#
msgid ""
msgstr ""
-"Project-Id-Version: OpenERP Server 6.1\n"
+"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-11-07 14:35+0000\n"
+"POT-Creation-Date: 2013-10-14 18:35+0000\n"
"PO-Revision-Date: 2012-11-07 14:35+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
+#. module: product_standard_margin
+#: help:product.product,standard_margin_rate:0
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+"Taux de marge théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
+"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
+"taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le "
+"taux sera de 999.0"
+
#. module: product_standard_margin
#: model:ir.model,name:product_standard_margin.model_product_product
msgid "Product"
msgstr "Produit"
#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin_rate
#: field:product.product,standard_margin_rate:0
msgid "Theorical Margin (%)"
msgstr "Marge Théorique (%)"
-#. module: product_standard_margin
-#: help:product.product,standard_margin_rate:0
-msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
-msgstr "Taux de marge théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du formulaire Produit] (ne tient pas compte de la facturation effective). Ce taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le taux sera de 999.0"
-
-#. module: product_standard_margin
-#: constraint:product.product:0
-msgid "Error: Invalid ean code"
-msgstr "Erreur : Code EAN invalide"
-
#. module: product_standard_margin
#: help:product.product,standard_margin:0
-msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).Take care of tax include and exclude. If no sale price, the margin will be negativ."
-msgstr "Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient pas compte de la facturation effective). Ce taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, la marge sera négative."
-
-#. module: product_standard_margin
-#: view:product.product:0
-msgid "Margin"
-msgstr "Marge"
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values). Take care of tax include and exclude. If "
+"no sale price, the margin will be negativ."
+msgstr ""
+"Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient "
+"pas compte de la facturation effective). Ce taux tient compte des PV TTC "
+"(TVA incluse). Si aucun PV n'a été saisi, la marge sera négative."
#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin
#: field:product.product,standard_margin:0
msgid "Theorical Margin"
msgstr "Marge Théorique"
-
From 3c5b7c34c77a2811ec212c0ceb7eb347c9b84ad0 Mon Sep 17 00:00:00 2001
From: Joel Grand-Guillaume
Date: Wed, 27 Nov 2013 15:03:12 +0100
Subject: [PATCH 19/80] [IMP] Better logger implementation
---
product_standard_margin/product_std_margin.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index fa97b668f..15d38038d 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -24,7 +24,7 @@
from openerp.osv import orm, fields
import decimal_precision as dp
import logging
-
+_logger = logging.getLogger(__name__)
class Product(orm.Model):
_inherit = 'product.product'
@@ -67,7 +67,7 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context=None):
'margin_relative': float}
}}
"""
- logger = logging.getLogger('product_standard_margin')
+
if context is None:
context = {}
res = {}
@@ -81,7 +81,7 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context=None):
[product.id], context=context)[product.id]
res[product.id]['standard_margin'] = sale - cost
if sale == 0:
- logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
+ _logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
res[product.id]['standard_margin_rate'] = 999.
else:
res[product.id]['standard_margin_rate'] = (sale - cost) / sale * 100
From 1d21ec8d93f4671085a7be48b2f1d81d5131b55f Mon Sep 17 00:00:00 2001
From: Joel Grand-Guillaume
Date: Wed, 27 Nov 2013 16:26:22 +0100
Subject: [PATCH 20/80] [FIX] Context propagation
---
product_standard_margin/product_std_margin.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index 15d38038d..055148932 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -43,7 +43,7 @@ def _amount_tax_excluded(self, cr, uid, ids, context=None):
if context is None:
context = {}
tax_obj = self.pool.get('account.tax')
- for prod in self.browse(cr, uid, ids):
+ for prod in self.browse(cr, uid, ids, context=context):
price = prod.list_price
taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
res[prod.id] = taxes['total']
@@ -75,7 +75,7 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context=None):
return res
for product in ids:
res[product] = {'margin_absolute': 0, 'margin_relative': 0}
- for product in self.browse(cursor, user, ids):
+ for product in self.browse(cursor, user, ids, context=context):
cost = product.cost_price
sale = self._amount_tax_excluded(cursor, user,
[product.id], context=context)[product.id]
From cbb705d7e4413ae33bd71788d19491a65b6304e0 Mon Sep 17 00:00:00 2001
From: Joel Grand-Guillaume
Date: Tue, 10 Dec 2013 14:29:31 +0100
Subject: [PATCH 21/80] [IMP] Use read whenever it's possible for performance
reasons
---
product_standard_margin/product_std_margin.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index 055148932..b2c28cf71 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -75,16 +75,16 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context=None):
return res
for product in ids:
res[product] = {'margin_absolute': 0, 'margin_relative': 0}
- for product in self.browse(cursor, user, ids, context=context):
- cost = product.cost_price
+ for product in self.read(cursor, user, ids, ['id','cost_price'], context=context):
+ cost = product['cost_price']
sale = self._amount_tax_excluded(cursor, user,
- [product.id], context=context)[product.id]
- res[product.id]['standard_margin'] = sale - cost
+ [product['id']], context=context)[product['id']]
+ res[product['id']]['standard_margin'] = sale - cost
if sale == 0:
- _logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
- res[product.id]['standard_margin_rate'] = 999.
+ _logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product['id'])
+ res[product['id']]['standard_margin_rate'] = 999.
else:
- res[product.id]['standard_margin_rate'] = (sale - cost) / sale * 100
+ res[product['id']]['standard_margin_rate'] = (sale - cost) / sale * 100
return res
_columns = {
From 5ae6ca809b396894985ebe4d52ebf82b66d06452 Mon Sep 17 00:00:00 2001
From: Yannick Vaucher
Date: Wed, 11 Dec 2013 16:30:40 +0100
Subject: [PATCH 22/80] [PEP8] product_standard_margin
---
product_standard_margin/product_std_margin.py | 78 ++++++++++---------
1 file changed, 43 insertions(+), 35 deletions(-)
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index b2c28cf71..7d4c7aadb 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -26,18 +26,21 @@
import logging
_logger = logging.getLogger(__name__)
+
class Product(orm.Model):
_inherit = 'product.product'
#TODO : compute the margin with default taxes
def _amount_tax_excluded(self, cr, uid, ids, context=None):
- """
- Compute the list price total without tax (in case you are in tax included).
+ """ Compute the list price total without tax
+
+ (in case you are in tax included).
This will use the default taxes defined on the product.
:return dict of values:
{INT Product ID:
float price without tax
}
+
"""
res = {}
if context is None:
@@ -49,25 +52,27 @@ def _amount_tax_excluded(self, cr, uid, ids, context=None):
res[prod.id] = taxes['total']
return res
- def _compute_margin(self, cursor, user, ids, field_name, arg, context=None):
- """
- Calculate the margin based on product infos. Take care of the cost_field
- define in product_get_cost_field. So the margin will be computed based on this
- field.
+ def _compute_margin(self, cr, user, ids, field_name, arg, context=None):
+ """ Calculate the margin based on product infos.
+
+ Take care of the cost_field define in product_get_cost_field. So the
+ margin will be computed based on this field.
- We don't take care of the product price type currency to remove the dependency on
- the sale module. We consider the cost and sale price is in the company currency.
+ We don't take care of the product price type currency to remove the
+ dependency on the sale module. We consider the cost and sale price is
+ in the company currency.
- We take care of the default product taxes, and base our computation on total without
- tax.
+ We take care of the default product taxes, and base our computation on
+ total without tax.
:return dict of dict of the form :
{INT Product ID : {
{'margin_absolute': float,
'margin_relative': float}
}}
+
"""
-
+
if context is None:
context = {}
res = {}
@@ -75,13 +80,16 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context=None):
return res
for product in ids:
res[product] = {'margin_absolute': 0, 'margin_relative': 0}
- for product in self.read(cursor, user, ids, ['id','cost_price'], context=context):
+ for product in self.read(cr, user, ids,
+ ['id', 'cost_price'], context=context):
cost = product['cost_price']
- sale = self._amount_tax_excluded(cursor, user,
- [product['id']], context=context)[product['id']]
+ sale = self._amount_tax_excluded(cr, user,
+ [product['id']],
+ context=context)[product['id']]
res[product['id']]['standard_margin'] = sale - cost
if sale == 0:
- _logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product['id'])
+ _logger.debug("Sale price for product ID %d is 0, cannot "
+ "compute margin rate...", product['id'])
res[product['id']]['standard_margin_rate'] = 999.
else:
res[product['id']]['standard_margin_rate'] = (sale - cost) / sale * 100
@@ -89,23 +97,23 @@ def _compute_margin(self, cursor, user, ids, field_name, arg, context=None):
_columns = {
'standard_margin': fields.function(
- _compute_margin,
- method=True,
- string='Theorical Margin',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Theorical Margin is [ sale price (Wo Tax) - cost price ] '
- 'of the product form (not based on historical values). '
- 'Take care of tax include and exclude. If no sale price, '
- 'the margin will be negativ.'),
+ _compute_margin,
+ method=True,
+ string='Theorical Margin',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Theorical Margin is [ sale price (Wo Tax) - cost price ] '
+ 'of the product form (not based on historical values). '
+ 'Take care of tax include and exclude. If no sale price, '
+ 'the margin will be negativ.'),
'standard_margin_rate': fields.function(
- _compute_margin,
- method=True,
- string='Theorical Margin (%)',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] '
- 'of the product form (not based on historical values).'
- 'Take care of tax include and exclude.. If no sale price '
- 'set, will display 999.0'),
- }
+ _compute_margin,
+ method=True,
+ string='Theorical Margin (%)',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] '
+ 'of the product form (not based on historical values).'
+ 'Take care of tax include and exclude.. If no sale price '
+ 'set, will display 999.0'),
+ }
From bebd58f9d05146d551691d70619485df2fcd66c8 Mon Sep 17 00:00:00 2001
From: Alexandre Fayolle
Date: Wed, 13 Aug 2014 16:09:16 +0200
Subject: [PATCH 23/80] all modules are unported on 8.0 branch
---
product_standard_margin/__init__.py | 22 ----
product_standard_margin/__openerp__.py | 54 --------
product_standard_margin/i18n/fr.po | 57 ---------
product_standard_margin/i18n/nl.po | 67 ----------
.../i18n/product_standard_margin.pot | 44 -------
product_standard_margin/product_std_margin.py | 119 ------------------
.../product_std_margin_view.xml | 20 ---
7 files changed, 383 deletions(-)
delete mode 100644 product_standard_margin/__init__.py
delete mode 100644 product_standard_margin/__openerp__.py
delete mode 100644 product_standard_margin/i18n/fr.po
delete mode 100644 product_standard_margin/i18n/nl.po
delete mode 100644 product_standard_margin/i18n/product_standard_margin.pot
delete mode 100644 product_standard_margin/product_std_margin.py
delete mode 100644 product_standard_margin/product_std_margin_view.xml
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
deleted file mode 100644
index 4a754ba5d..000000000
--- a/product_standard_margin/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-from . import product_std_margin
-
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
deleted file mode 100644
index d5f28959b..000000000
--- a/product_standard_margin/__openerp__.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-{'name': 'Markup rate on product and sales',
- 'version': '1.0',
- 'author': 'Camptocamp',
- 'maintainer': 'Camptocamp',
- 'category': 'Sales Management',
- 'complexity': "normal", # easy, normal, expert
- 'depends': ['product_get_cost_field', 'account'],
- 'description': """
- Add a field on the product form that compute the standard (or theorical) margin based on the
- current values of sale and cost price present in the product form. We take care of taxe included
- or excluded.
-
- It will just compute it as follow: (Sale Price without tax - Cost Price) / Sale Price without tax
-
- Remember that this module can be used in conjonction with product_cost_incl_bom to have the
- cost price computed from the BOM when a product has one.
-
- WARNING:
-
- 1) As this module will base his simple computation on sale and cost prices, it suppose
- you have them both in the same currency (the price type must of the same currency for both of
- them). Remember this is the default OpenERP configuration (price type of all product price
- fields are set as the same as the company currency). We don't take care of it cause otherwise
- we should have added a dependency on sale module.
-
- """,
- 'website': 'http://www.camptocamp.com/',
- 'init_xml': [],
- 'data': ['product_std_margin_view.xml'],
- 'tests': [],
- 'installable': True,
- 'auto_install': False,
- 'license': 'AGPL-3',
- 'application': True}
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
deleted file mode 100644
index 228f7994f..000000000
--- a/product_standard_margin/i18n/fr.po
+++ /dev/null
@@ -1,57 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * product_standard_margin
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 7.0\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-10-14 18:35+0000\n"
-"PO-Revision-Date: 2012-11-07 14:35+0000\n"
-"Last-Translator: <>\n"
-"Language-Team: \n"
-"Language: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Plural-Forms: \n"
-
-#. module: product_standard_margin
-#: help:product.product,standard_margin_rate:0
-msgid ""
-"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.. "
-"If no sale price set, will display 999.0"
-msgstr ""
-"Taux de marge théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
-"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
-"taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le "
-"taux sera de 999.0"
-
-#. module: product_standard_margin
-#: model:ir.model,name:product_standard_margin.model_product_product
-msgid "Product"
-msgstr "Produit"
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin_rate
-#: field:product.product,standard_margin_rate:0
-msgid "Theorical Margin (%)"
-msgstr "Marge Théorique (%)"
-
-#. module: product_standard_margin
-#: help:product.product,standard_margin:0
-msgid ""
-"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
-"(not based on historical values). Take care of tax include and exclude. If "
-"no sale price, the margin will be negativ."
-msgstr ""
-"Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient "
-"pas compte de la facturation effective). Ce taux tient compte des PV TTC "
-"(TVA incluse). Si aucun PV n'a été saisi, la marge sera négative."
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin
-#: field:product.product,standard_margin:0
-msgid "Theorical Margin"
-msgstr "Marge Théorique"
diff --git a/product_standard_margin/i18n/nl.po b/product_standard_margin/i18n/nl.po
deleted file mode 100644
index 554bdeb5a..000000000
--- a/product_standard_margin/i18n/nl.po
+++ /dev/null
@@ -1,67 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * product_standard_margin
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 6.1\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-12-23 12:04+0000\n"
-"PO-Revision-Date: 2012-12-23 13:35+0100\n"
-"Last-Translator: Erwin van der Ploeg | Endian Solutions "
-"\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: \n"
-"X-Generator: Poedit 1.5.4\n"
-
-#. module: product_standard_margin
-#: model:ir.model,name:product_standard_margin.model_product_product
-msgid "Product"
-msgstr "Product"
-
-#. module: product_standard_margin
-#: field:product.product,standard_margin_rate:0
-msgid "Theorical Margin (%)"
-msgstr "Theoretische marge (%)"
-
-#. module: product_standard_margin
-#: help:product.product,standard_margin_rate:0
-msgid ""
-"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.. "
-"If no sale price set, will display 999.0"
-msgstr ""
-"Theoretische marge (%) is [ Theoretische marge / Verkoopprijs (excl. BTW) ] "
-"van het product (niet gebaseerd op historische waardes). Het veld houdt "
-"rekening met prijzen incl. en excl. BTW. Indien geen verkooprijs is "
-"ingevoerd, wordt 999,0 weergegeven."
-
-#. module: product_standard_margin
-#: constraint:product.product:0
-msgid "Error: Invalid ean code"
-msgstr "Fout: ongeldige ean code"
-
-#. module: product_standard_margin
-#: help:product.product,standard_margin:0
-msgid ""
-"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
-"(not based on historical values).Take care of tax include and exclude. If no "
-"sale price, the margin will be negativ."
-msgstr ""
-"Theoretische marge is [ Verkoopprijs (excl. BTW) - Kostprijs) ] van het "
-"product (niet gebaseerd op historische waardes). Het veld houdt rekening met "
-"prijzen incl. en excl. BTW. Indien geen verkooprijs is ingevoerd, zal de "
-"marge negatief zijn."
-
-#. module: product_standard_margin
-#: view:product.product:0
-msgid "Margin"
-msgstr "Marge"
-
-#. module: product_standard_margin
-#: field:product.product,standard_margin:0
-msgid "Theorical Margin"
-msgstr "Theoretische marge"
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
deleted file mode 100644
index 264b76eda..000000000
--- a/product_standard_margin/i18n/product_standard_margin.pot
+++ /dev/null
@@ -1,44 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * product_standard_margin
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 7.0\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-10-14 18:35+0000\n"
-"PO-Revision-Date: 2013-10-14 18:35+0000\n"
-"Last-Translator: <>\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Plural-Forms: \n"
-
-#. module: product_standard_margin
-#: help:product.product,standard_margin_rate:0
-msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model,name:product_standard_margin.model_product_product
-msgid "Product"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin_rate
-#: field:product.product,standard_margin_rate:0
-msgid "Theorical Margin (%)"
-msgstr ""
-
-#. module: product_standard_margin
-#: help:product.product,standard_margin:0
-msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin
-#: field:product.product,standard_margin:0
-msgid "Theorical Margin"
-msgstr ""
-
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
deleted file mode 100644
index 7d4c7aadb..000000000
--- a/product_standard_margin/product_std_margin.py
+++ /dev/null
@@ -1,119 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2012 Camptocamp SA (http://www.camptocamp.com)
-# All Right Reserved
-#
-# Author : Joel Grand-Guillaume
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-from openerp.osv import orm, fields
-import decimal_precision as dp
-import logging
-_logger = logging.getLogger(__name__)
-
-
-class Product(orm.Model):
- _inherit = 'product.product'
-
- #TODO : compute the margin with default taxes
- def _amount_tax_excluded(self, cr, uid, ids, context=None):
- """ Compute the list price total without tax
-
- (in case you are in tax included).
- This will use the default taxes defined on the product.
- :return dict of values:
- {INT Product ID:
- float price without tax
- }
-
- """
- res = {}
- if context is None:
- context = {}
- tax_obj = self.pool.get('account.tax')
- for prod in self.browse(cr, uid, ids, context=context):
- price = prod.list_price
- taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
- res[prod.id] = taxes['total']
- return res
-
- def _compute_margin(self, cr, user, ids, field_name, arg, context=None):
- """ Calculate the margin based on product infos.
-
- Take care of the cost_field define in product_get_cost_field. So the
- margin will be computed based on this field.
-
- We don't take care of the product price type currency to remove the
- dependency on the sale module. We consider the cost and sale price is
- in the company currency.
-
- We take care of the default product taxes, and base our computation on
- total without tax.
-
- :return dict of dict of the form :
- {INT Product ID : {
- {'margin_absolute': float,
- 'margin_relative': float}
- }}
-
- """
-
- if context is None:
- context = {}
- res = {}
- if not ids:
- return res
- for product in ids:
- res[product] = {'margin_absolute': 0, 'margin_relative': 0}
- for product in self.read(cr, user, ids,
- ['id', 'cost_price'], context=context):
- cost = product['cost_price']
- sale = self._amount_tax_excluded(cr, user,
- [product['id']],
- context=context)[product['id']]
- res[product['id']]['standard_margin'] = sale - cost
- if sale == 0:
- _logger.debug("Sale price for product ID %d is 0, cannot "
- "compute margin rate...", product['id'])
- res[product['id']]['standard_margin_rate'] = 999.
- else:
- res[product['id']]['standard_margin_rate'] = (sale - cost) / sale * 100
- return res
-
- _columns = {
- 'standard_margin': fields.function(
- _compute_margin,
- method=True,
- string='Theorical Margin',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Theorical Margin is [ sale price (Wo Tax) - cost price ] '
- 'of the product form (not based on historical values). '
- 'Take care of tax include and exclude. If no sale price, '
- 'the margin will be negativ.'),
- 'standard_margin_rate': fields.function(
- _compute_margin,
- method=True,
- string='Theorical Margin (%)',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] '
- 'of the product form (not based on historical values).'
- 'Take care of tax include and exclude.. If no sale price '
- 'set, will display 999.0'),
- }
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
deleted file mode 100644
index 07cfa3135..000000000
--- a/product_standard_margin/product_std_margin_view.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
- product.markup.view.form
- form
- product.product
-
-
-
-
-
-
-
-
-
-
-
-
-
From 0b4ff2eda19d3b81ec56874d57a9436984ed5ad6 Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Fri, 24 Jul 2015 09:29:36 +0200
Subject: [PATCH 24/80] [PORT][WIP] move 'product_standard_margin' from
unported to regular folder;
---
product_standard_margin/__init__.py | 22 ++++
product_standard_margin/__openerp__.py | 54 ++++++++
product_standard_margin/i18n/fr.po | 57 +++++++++
product_standard_margin/i18n/nl.po | 67 ++++++++++
.../i18n/product_standard_margin.pot | 44 +++++++
product_standard_margin/product_std_margin.py | 119 ++++++++++++++++++
.../product_std_margin_view.xml | 20 +++
7 files changed, 383 insertions(+)
create mode 100644 product_standard_margin/__init__.py
create mode 100644 product_standard_margin/__openerp__.py
create mode 100644 product_standard_margin/i18n/fr.po
create mode 100644 product_standard_margin/i18n/nl.po
create mode 100644 product_standard_margin/i18n/product_standard_margin.pot
create mode 100644 product_standard_margin/product_std_margin.py
create mode 100644 product_standard_margin/product_std_margin_view.xml
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
new file mode 100644
index 000000000..4a754ba5d
--- /dev/null
+++ b/product_standard_margin/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import product_std_margin
+
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
new file mode 100644
index 000000000..e9069f0c5
--- /dev/null
+++ b/product_standard_margin/__openerp__.py
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+{'name': 'Markup rate on product and sales',
+ 'version': '1.0',
+ 'author': "Camptocamp,Odoo Community Association (OCA)",
+ 'maintainer': 'Camptocamp',
+ 'category': 'Sales Management',
+ 'complexity': "normal", # easy, normal, expert
+ 'depends': ['product_get_cost_field', 'account'],
+ 'description': """
+ Add a field on the product form that compute the standard (or theorical) margin based on the
+ current values of sale and cost price present in the product form. We take care of taxe included
+ or excluded.
+
+ It will just compute it as follow: (Sale Price without tax - Cost Price) / Sale Price without tax
+
+ Remember that this module can be used in conjonction with product_cost_incl_bom to have the
+ cost price computed from the BOM when a product has one.
+
+ WARNING:
+
+ 1) As this module will base his simple computation on sale and cost prices, it suppose
+ you have them both in the same currency (the price type must of the same currency for both of
+ them). Remember this is the default OpenERP configuration (price type of all product price
+ fields are set as the same as the company currency). We don't take care of it cause otherwise
+ we should have added a dependency on sale module.
+
+ """,
+ 'website': 'http://www.camptocamp.com/',
+ 'init_xml': [],
+ 'data': ['product_std_margin_view.xml'],
+ 'tests': [],
+ 'installable': False,
+ 'auto_install': False,
+ 'license': 'AGPL-3',
+ 'application': True}
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
new file mode 100644
index 000000000..228f7994f
--- /dev/null
+++ b/product_standard_margin/i18n/fr.po
@@ -0,0 +1,57 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-10-14 18:35+0000\n"
+"PO-Revision-Date: 2012-11-07 14:35+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin_rate:0
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+"Taux de marge théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
+"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
+"taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le "
+"taux sera de 999.0"
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr "Produit"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin_rate
+#: field:product.product,standard_margin_rate:0
+msgid "Theorical Margin (%)"
+msgstr "Marge Théorique (%)"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin:0
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values). Take care of tax include and exclude. If "
+"no sale price, the margin will be negativ."
+msgstr ""
+"Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient "
+"pas compte de la facturation effective). Ce taux tient compte des PV TTC "
+"(TVA incluse). Si aucun PV n'a été saisi, la marge sera négative."
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin
+#: field:product.product,standard_margin:0
+msgid "Theorical Margin"
+msgstr "Marge Théorique"
diff --git a/product_standard_margin/i18n/nl.po b/product_standard_margin/i18n/nl.po
new file mode 100644
index 000000000..554bdeb5a
--- /dev/null
+++ b/product_standard_margin/i18n/nl.po
@@ -0,0 +1,67 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-12-23 12:04+0000\n"
+"PO-Revision-Date: 2012-12-23 13:35+0100\n"
+"Last-Translator: Erwin van der Ploeg | Endian Solutions "
+"\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+"X-Generator: Poedit 1.5.4\n"
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr "Product"
+
+#. module: product_standard_margin
+#: field:product.product,standard_margin_rate:0
+msgid "Theorical Margin (%)"
+msgstr "Theoretische marge (%)"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin_rate:0
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+"Theoretische marge (%) is [ Theoretische marge / Verkoopprijs (excl. BTW) ] "
+"van het product (niet gebaseerd op historische waardes). Het veld houdt "
+"rekening met prijzen incl. en excl. BTW. Indien geen verkooprijs is "
+"ingevoerd, wordt 999,0 weergegeven."
+
+#. module: product_standard_margin
+#: constraint:product.product:0
+msgid "Error: Invalid ean code"
+msgstr "Fout: ongeldige ean code"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin:0
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values).Take care of tax include and exclude. If no "
+"sale price, the margin will be negativ."
+msgstr ""
+"Theoretische marge is [ Verkoopprijs (excl. BTW) - Kostprijs) ] van het "
+"product (niet gebaseerd op historische waardes). Het veld houdt rekening met "
+"prijzen incl. en excl. BTW. Indien geen verkooprijs is ingevoerd, zal de "
+"marge negatief zijn."
+
+#. module: product_standard_margin
+#: view:product.product:0
+msgid "Margin"
+msgstr "Marge"
+
+#. module: product_standard_margin
+#: field:product.product,standard_margin:0
+msgid "Theorical Margin"
+msgstr "Theoretische marge"
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
new file mode 100644
index 000000000..264b76eda
--- /dev/null
+++ b/product_standard_margin/i18n/product_standard_margin.pot
@@ -0,0 +1,44 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-10-14 18:35+0000\n"
+"PO-Revision-Date: 2013-10-14 18:35+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin_rate:0
+msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin_rate
+#: field:product.product,standard_margin_rate:0
+msgid "Theorical Margin (%)"
+msgstr ""
+
+#. module: product_standard_margin
+#: help:product.product,standard_margin:0
+msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin
+#: field:product.product,standard_margin:0
+msgid "Theorical Margin"
+msgstr ""
+
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
new file mode 100644
index 000000000..7d4c7aadb
--- /dev/null
+++ b/product_standard_margin/product_std_margin.py
@@ -0,0 +1,119 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2012 Camptocamp SA (http://www.camptocamp.com)
+# All Right Reserved
+#
+# Author : Joel Grand-Guillaume
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+import decimal_precision as dp
+import logging
+_logger = logging.getLogger(__name__)
+
+
+class Product(orm.Model):
+ _inherit = 'product.product'
+
+ #TODO : compute the margin with default taxes
+ def _amount_tax_excluded(self, cr, uid, ids, context=None):
+ """ Compute the list price total without tax
+
+ (in case you are in tax included).
+ This will use the default taxes defined on the product.
+ :return dict of values:
+ {INT Product ID:
+ float price without tax
+ }
+
+ """
+ res = {}
+ if context is None:
+ context = {}
+ tax_obj = self.pool.get('account.tax')
+ for prod in self.browse(cr, uid, ids, context=context):
+ price = prod.list_price
+ taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
+ res[prod.id] = taxes['total']
+ return res
+
+ def _compute_margin(self, cr, user, ids, field_name, arg, context=None):
+ """ Calculate the margin based on product infos.
+
+ Take care of the cost_field define in product_get_cost_field. So the
+ margin will be computed based on this field.
+
+ We don't take care of the product price type currency to remove the
+ dependency on the sale module. We consider the cost and sale price is
+ in the company currency.
+
+ We take care of the default product taxes, and base our computation on
+ total without tax.
+
+ :return dict of dict of the form :
+ {INT Product ID : {
+ {'margin_absolute': float,
+ 'margin_relative': float}
+ }}
+
+ """
+
+ if context is None:
+ context = {}
+ res = {}
+ if not ids:
+ return res
+ for product in ids:
+ res[product] = {'margin_absolute': 0, 'margin_relative': 0}
+ for product in self.read(cr, user, ids,
+ ['id', 'cost_price'], context=context):
+ cost = product['cost_price']
+ sale = self._amount_tax_excluded(cr, user,
+ [product['id']],
+ context=context)[product['id']]
+ res[product['id']]['standard_margin'] = sale - cost
+ if sale == 0:
+ _logger.debug("Sale price for product ID %d is 0, cannot "
+ "compute margin rate...", product['id'])
+ res[product['id']]['standard_margin_rate'] = 999.
+ else:
+ res[product['id']]['standard_margin_rate'] = (sale - cost) / sale * 100
+ return res
+
+ _columns = {
+ 'standard_margin': fields.function(
+ _compute_margin,
+ method=True,
+ string='Theorical Margin',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Theorical Margin is [ sale price (Wo Tax) - cost price ] '
+ 'of the product form (not based on historical values). '
+ 'Take care of tax include and exclude. If no sale price, '
+ 'the margin will be negativ.'),
+ 'standard_margin_rate': fields.function(
+ _compute_margin,
+ method=True,
+ string='Theorical Margin (%)',
+ digits_compute=dp.get_precision('Sale Price'),
+ multi='margin',
+ help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] '
+ 'of the product form (not based on historical values).'
+ 'Take care of tax include and exclude.. If no sale price '
+ 'set, will display 999.0'),
+ }
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/product_std_margin_view.xml
new file mode 100644
index 000000000..07cfa3135
--- /dev/null
+++ b/product_standard_margin/product_std_margin_view.xml
@@ -0,0 +1,20 @@
+
+
+
+
+ product.markup.view.form
+ form
+ product.product
+
+
+
+
+
+
+
+
+
+
+
+
+
From 35d4c1e4660b23da28cbb7cbecc703c15811a917 Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Fri, 24 Jul 2015 09:33:14 +0200
Subject: [PATCH 25/80] [PORT][WIP] port somes commit from V7 branches,
specially 18bf9614b1c58f39ec8bdbd53cf4363faceaa9c1 that make standard_margin
and standard_margin_rate stored fields;
---
product_standard_margin/__init__.py | 1 -
product_standard_margin/__openerp__.py | 30 +++++-----
product_standard_margin/product_std_margin.py | 58 +++++++++++++------
3 files changed, 58 insertions(+), 31 deletions(-)
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
index 4a754ba5d..04072607e 100644
--- a/product_standard_margin/__init__.py
+++ b/product_standard_margin/__init__.py
@@ -19,4 +19,3 @@
#
##############################################################################
from . import product_std_margin
-
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index e9069f0c5..0c976ec64 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -24,31 +24,35 @@
'maintainer': 'Camptocamp',
'category': 'Sales Management',
'complexity': "normal", # easy, normal, expert
- 'depends': ['product_get_cost_field', 'account'],
+ 'depends': ['product_get_cost_field',
+ 'account'],
'description': """
- Add a field on the product form that compute the standard (or theorical) margin based on the
- current values of sale and cost price present in the product form. We take care of taxe included
- or excluded.
+ Add a field on the product form that compute the standard (or theorical)
+ margin based on the current values of sale and cost price present in the
+ product form. We take care of taxe included or excluded.
- It will just compute it as follow: (Sale Price without tax - Cost Price) / Sale Price without tax
+ It will just compute it as follow: (Sale Price without tax - Cost Price) /
+ Sale Price without tax
- Remember that this module can be used in conjonction with product_cost_incl_bom to have the
- cost price computed from the BOM when a product has one.
+ Remember that this module can be used in conjonction with
+ product_cost_incl_bom to have the cost price computed from the BOM when a
+ product has one.
WARNING:
- 1) As this module will base his simple computation on sale and cost prices, it suppose
- you have them both in the same currency (the price type must of the same currency for both of
- them). Remember this is the default OpenERP configuration (price type of all product price
- fields are set as the same as the company currency). We don't take care of it cause otherwise
- we should have added a dependency on sale module.
+ 1) As this module will base his simple computation on sale and cost prices,
+ it suppose you have them both in the same currency (the price type must of
+ the same currency for both of them). Remember this is the default OpenERP
+ configuration (price type of all product price fields are set as the same as
+ the company currency). We don't take care of it cause otherwise we should
+ have added a dependency on sale module.
""",
'website': 'http://www.camptocamp.com/',
'init_xml': [],
'data': ['product_std_margin_view.xml'],
'tests': [],
- 'installable': False,
+ 'installable': True,
'auto_install': False,
'license': 'AGPL-3',
'application': True}
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/product_std_margin.py
index 7d4c7aadb..408a07dd8 100644
--- a/product_standard_margin/product_std_margin.py
+++ b/product_standard_margin/product_std_margin.py
@@ -27,10 +27,10 @@
_logger = logging.getLogger(__name__)
-class Product(orm.Model):
+class ProductProduct(orm.Model):
_inherit = 'product.product'
- #TODO : compute the margin with default taxes
+ # TODO : compute the margin with default taxes
def _amount_tax_excluded(self, cr, uid, ids, context=None):
""" Compute the list price total without tax
@@ -48,7 +48,11 @@ def _amount_tax_excluded(self, cr, uid, ids, context=None):
tax_obj = self.pool.get('account.tax')
for prod in self.browse(cr, uid, ids, context=context):
price = prod.list_price
- taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
+ taxes = tax_obj.compute_all(cr, uid,
+ prod.taxes_id,
+ price,
+ 1,
+ product=prod.id)
res[prod.id] = taxes['total']
return res
@@ -67,37 +71,56 @@ def _compute_margin(self, cr, user, ids, field_name, arg, context=None):
:return dict of dict of the form :
{INT Product ID : {
- {'margin_absolute': float,
- 'margin_relative': float}
+ {'standard_margin': float,
+ 'standard_margin_rate': float}
}}
"""
-
- if context is None:
- context = {}
- res = {}
- if not ids:
- return res
- for product in ids:
- res[product] = {'margin_absolute': 0, 'margin_relative': 0}
+ context = context and context or {}
+ res = {id: {} for id in ids}
for product in self.read(cr, user, ids,
['id', 'cost_price'], context=context):
cost = product['cost_price']
sale = self._amount_tax_excluded(cr, user,
[product['id']],
context=context)[product['id']]
- res[product['id']]['standard_margin'] = sale - cost
+ _res = res[product['id']]
+ _res['standard_margin'] = sale - cost
if sale == 0:
_logger.debug("Sale price for product ID %d is 0, cannot "
- "compute margin rate...", product['id'])
- res[product['id']]['standard_margin_rate'] = 999.
+ "compute margin rate...",
+ product['id'])
+ _res['standard_margin_rate'] = 999.
else:
- res[product['id']]['standard_margin_rate'] = (sale - cost) / sale * 100
+ _res['standard_margin_rate'] = (sale - cost) / sale * 100
return res
+ def _get_product_margin_change_from_tax(self, cr, uid, ids, context=None):
+ """Find the products to trigger when a Tax changes"""
+ pt_obj = self.pool['product.template']
+ pp_obj = self.pool['product.product']
+ pt_ids = pt_obj.search(cr, uid, [
+ '|', ('taxes_id', 'in', ids),
+ ('supplier_taxes_id', 'in', ids)], context=context)
+ pp_ids = pp_obj.search(
+ cr, uid, [('product_tmpl_id', 'in', pt_ids)], context=context)
+ return pp_ids
+
+ _margin_triggers = {
+ 'product.product': (
+ lambda self, cr, uid, ids, context=None:
+ ids, None, 10),
+ 'account.tax': (
+ _get_product_margin_change_from_tax, [
+ 'type', 'price_include', 'amount',
+ 'include_base_amount', 'child_depend'],
+ 10),
+ }
+
_columns = {
'standard_margin': fields.function(
_compute_margin,
+ store=_margin_triggers,
method=True,
string='Theorical Margin',
digits_compute=dp.get_precision('Sale Price'),
@@ -108,6 +131,7 @@ def _compute_margin(self, cr, user, ids, field_name, arg, context=None):
'the margin will be negativ.'),
'standard_margin_rate': fields.function(
_compute_margin,
+ store=_margin_triggers,
method=True,
string='Theorical Margin (%)',
digits_compute=dp.get_precision('Sale Price'),
From 4d3bc38b62d541be9ae0c18d9b571da480398319 Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Fri, 24 Jul 2015 09:43:25 +0200
Subject: [PATCH 26/80] [PORT][REF] OCA convention;
---
product_standard_margin/__init__.py | 2 +-
product_standard_margin/__openerp__.py | 4 +++-
product_standard_margin/models/__init__.py | 21 +++++++++++++++++++
.../product_product.py} | 0
.../view.xml} | 0
5 files changed, 25 insertions(+), 2 deletions(-)
create mode 100644 product_standard_margin/models/__init__.py
rename product_standard_margin/{product_std_margin.py => models/product_product.py} (100%)
rename product_standard_margin/{product_std_margin_view.xml => views/view.xml} (100%)
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
index 04072607e..54f620f43 100644
--- a/product_standard_margin/__init__.py
+++ b/product_standard_margin/__init__.py
@@ -18,4 +18,4 @@
# along with this program. If not, see .
#
##############################################################################
-from . import product_std_margin
+from . import models
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index 0c976ec64..2f82b357f 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -50,7 +50,9 @@
""",
'website': 'http://www.camptocamp.com/',
'init_xml': [],
- 'data': ['product_std_margin_view.xml'],
+ 'data': [
+ 'views/view.xml',
+],
'tests': [],
'installable': True,
'auto_install': False,
diff --git a/product_standard_margin/models/__init__.py b/product_standard_margin/models/__init__.py
new file mode 100644
index 000000000..8d4366b62
--- /dev/null
+++ b/product_standard_margin/models/__init__.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Joel Grand-Guillaume
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import product_product
diff --git a/product_standard_margin/product_std_margin.py b/product_standard_margin/models/product_product.py
similarity index 100%
rename from product_standard_margin/product_std_margin.py
rename to product_standard_margin/models/product_product.py
diff --git a/product_standard_margin/product_std_margin_view.xml b/product_standard_margin/views/view.xml
similarity index 100%
rename from product_standard_margin/product_std_margin_view.xml
rename to product_standard_margin/views/view.xml
From 5965cb77492fc6085d4e6cfd9f07f4db7a437246 Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Fri, 24 Jul 2015 17:31:00 +0200
Subject: [PATCH 27/80] [REF] V8 api; [FIX] margin precision; [REF] new
description in readme file; [ADD] new 'field list_price_vat_excl';
---
product_standard_margin/README.rst | 55 +++++++
product_standard_margin/__init__.py | 1 +
product_standard_margin/__openerp__.py | 56 ++-----
.../data/decimal_precision.yml | 24 +++
.../models/product_product.py | 153 +++++-------------
product_standard_margin/views/view.xml | 31 ++--
6 files changed, 153 insertions(+), 167 deletions(-)
create mode 100644 product_standard_margin/README.rst
create mode 100644 product_standard_margin/data/decimal_precision.yml
diff --git a/product_standard_margin/README.rst b/product_standard_margin/README.rst
new file mode 100644
index 000000000..1c5c9e351
--- /dev/null
+++ b/product_standard_margin/README.rst
@@ -0,0 +1,55 @@
+Product Margin and Margin Rate
+==============================
+
+Add a field on the product form that compute the standard (or theorical)
+margin based on the current values of sale and replenishment cost present in
+the product form. We take care of taxe included or excluded.
+
+It will just compute it as follow:
+(Sale Price without tax - Replenishment Cost) / Sale Price without tax
+
+Remember that this module can be used in conjonction with
+product_cost_incl_bom to have the replenishment cost computed from the BOM when
+a product has one.
+
+ WARNING:
+
+ 1) As this module will base his simple computation on sale and cost prices,
+ it suppose you have them both in the same currency (the price type must of
+ the same currency for both of them). Remember this is the default OpenERP
+ configuration (price type of all product price fields are set as the same as
+ the company currency). We don't take care of it cause otherwise we should
+ have added a dependency on sale module.
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues `_.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
+`here `_.
+
+Credits
+=======
+
+Contributors
+------------
+
+* Alexandre Fayolle
+* Yannick Vaucher
+* Joël Grand-Guillaume
+* Sylvain Le Gal (https://twitter.com/legalsylvain)
+
+Maintainer
+----------
+
+.. image:: http://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: http://odoo-community.org
+
+This module is maintained by the OCA.
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
+
+To contribute to this module, please visit http://odoo-community.org.
+
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
index 54f620f43..cb1a1975c 100644
--- a/product_standard_margin/__init__.py
+++ b/product_standard_margin/__init__.py
@@ -18,4 +18,5 @@
# along with this program. If not, see .
#
##############################################################################
+
from . import models
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index 2f82b357f..5db420157 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -18,43 +18,19 @@
# along with this program. If not, see .
#
##############################################################################
-{'name': 'Markup rate on product and sales',
- 'version': '1.0',
- 'author': "Camptocamp,Odoo Community Association (OCA)",
- 'maintainer': 'Camptocamp',
- 'category': 'Sales Management',
- 'complexity': "normal", # easy, normal, expert
- 'depends': ['product_get_cost_field',
- 'account'],
- 'description': """
- Add a field on the product form that compute the standard (or theorical)
- margin based on the current values of sale and cost price present in the
- product form. We take care of taxe included or excluded.
-
- It will just compute it as follow: (Sale Price without tax - Cost Price) /
- Sale Price without tax
-
- Remember that this module can be used in conjonction with
- product_cost_incl_bom to have the cost price computed from the BOM when a
- product has one.
-
- WARNING:
-
- 1) As this module will base his simple computation on sale and cost prices,
- it suppose you have them both in the same currency (the price type must of
- the same currency for both of them). Remember this is the default OpenERP
- configuration (price type of all product price fields are set as the same as
- the company currency). We don't take care of it cause otherwise we should
- have added a dependency on sale module.
-
- """,
- 'website': 'http://www.camptocamp.com/',
- 'init_xml': [],
- 'data': [
- 'views/view.xml',
-],
- 'tests': [],
- 'installable': True,
- 'auto_install': False,
- 'license': 'AGPL-3',
- 'application': True}
+{
+ 'name': 'Product Margin and Margin Rate',
+ 'version': '2.0',
+ 'author': 'Camptocamp,GRAP,Odoo Community Association (OCA)',
+ 'category': 'Product',
+ 'depends': [
+ 'product_replenishment_cost',
+ 'account',
+ ],
+ 'website': 'http://www.camptocamp.com/',
+ 'data': [
+ 'data/decimal_precision.yml',
+ 'views/view.xml',
+ ],
+ 'license': 'AGPL-3',
+}
diff --git a/product_standard_margin/data/decimal_precision.yml b/product_standard_margin/data/decimal_precision.yml
new file mode 100644
index 000000000..c96bcc573
--- /dev/null
+++ b/product_standard_margin/data/decimal_precision.yml
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Copyright (C) 2015-Today GRAP (http://www.grap.coop)
+# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+- !record {model: decimal.precision, id: product_margin_precision}:
+ name: Product Margin Precision
+ digits: 2
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 408a07dd8..657e1f879 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -21,123 +21,54 @@
#
##############################################################################
-from openerp.osv import orm, fields
-import decimal_precision as dp
-import logging
-_logger = logging.getLogger(__name__)
+from openerp import fields, api
+from openerp.models import Model
+import openerp.addons.decimal_precision as dp
-class ProductProduct(orm.Model):
+class ProductProduct(Model):
_inherit = 'product.product'
- # TODO : compute the margin with default taxes
- def _amount_tax_excluded(self, cr, uid, ids, context=None):
- """ Compute the list price total without tax
+ @api.multi
+ @api.depends(
+ 'product_tmpl_id.list_price', 'replenishment_cost', 'taxes_id.type',
+ 'taxes_id.price_include', 'taxes_id.amount',
+ 'taxes_id.include_base_amount', 'taxes_id.child_depend')
+ def _get_margin(self):
+ print "_get_margin"
+ tax_obj = self.pool['account.tax']
+ for product in self:
+ product.list_price_vat_excl = tax_obj.compute_all(
+ self.env.cr, self.env.uid, product.taxes_id,
+ product.list_price, 1, product=product.id)['total']
- (in case you are in tax included).
- This will use the default taxes defined on the product.
- :return dict of values:
- {INT Product ID:
- float price without tax
- }
-
- """
- res = {}
- if context is None:
- context = {}
- tax_obj = self.pool.get('account.tax')
- for prod in self.browse(cr, uid, ids, context=context):
- price = prod.list_price
- taxes = tax_obj.compute_all(cr, uid,
- prod.taxes_id,
- price,
- 1,
- product=prod.id)
- res[prod.id] = taxes['total']
- return res
-
- def _compute_margin(self, cr, user, ids, field_name, arg, context=None):
- """ Calculate the margin based on product infos.
-
- Take care of the cost_field define in product_get_cost_field. So the
- margin will be computed based on this field.
-
- We don't take care of the product price type currency to remove the
- dependency on the sale module. We consider the cost and sale price is
- in the company currency.
-
- We take care of the default product taxes, and base our computation on
- total without tax.
-
- :return dict of dict of the form :
- {INT Product ID : {
- {'standard_margin': float,
- 'standard_margin_rate': float}
- }}
-
- """
- context = context and context or {}
- res = {id: {} for id in ids}
- for product in self.read(cr, user, ids,
- ['id', 'cost_price'], context=context):
- cost = product['cost_price']
- sale = self._amount_tax_excluded(cr, user,
- [product['id']],
- context=context)[product['id']]
- _res = res[product['id']]
- _res['standard_margin'] = sale - cost
- if sale == 0:
- _logger.debug("Sale price for product ID %d is 0, cannot "
- "compute margin rate...",
- product['id'])
- _res['standard_margin_rate'] = 999.
+ product.standard_margin =\
+ product.list_price_vat_excl - product.replenishment_cost
+ if product.list_price_vat_excl == 0:
+ product.standard_margin_rate = 999.
else:
- _res['standard_margin_rate'] = (sale - cost) / sale * 100
- return res
+ product.standard_margin_rate = (
+ (product.list_price_vat_excl - product.replenishment_cost) /
+ product.list_price_vat_excl * 100)
- def _get_product_margin_change_from_tax(self, cr, uid, ids, context=None):
- """Find the products to trigger when a Tax changes"""
- pt_obj = self.pool['product.template']
- pp_obj = self.pool['product.product']
- pt_ids = pt_obj.search(cr, uid, [
- '|', ('taxes_id', 'in', ids),
- ('supplier_taxes_id', 'in', ids)], context=context)
- pp_ids = pp_obj.search(
- cr, uid, [('product_tmpl_id', 'in', pt_ids)], context=context)
- return pp_ids
+ # Column Section
+ list_price_vat_excl = fields.Float(
+ compute=_get_margin, string='Sale Price VAT Excluded', store=True,
+ digits_compute=dp.get_precision('Product Price'),
+ )
- _margin_triggers = {
- 'product.product': (
- lambda self, cr, uid, ids, context=None:
- ids, None, 10),
- 'account.tax': (
- _get_product_margin_change_from_tax, [
- 'type', 'price_include', 'amount',
- 'include_base_amount', 'child_depend'],
- 10),
- }
+ standard_margin = fields.Float(
+ compute=_get_margin, string='Theorical Margin', store=True,
+ digits_compute=dp.get_precision('Product Price'),
+ help='Theorical Margin is [ sale price (Wo Tax) - cost price ] '
+ 'of the product form (not based on historical values). '
+ 'Take care of tax include and exclude. If no sale price, '
+ 'the margin will be negativ.')
- _columns = {
- 'standard_margin': fields.function(
- _compute_margin,
- store=_margin_triggers,
- method=True,
- string='Theorical Margin',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Theorical Margin is [ sale price (Wo Tax) - cost price ] '
- 'of the product form (not based on historical values). '
- 'Take care of tax include and exclude. If no sale price, '
- 'the margin will be negativ.'),
- 'standard_margin_rate': fields.function(
- _compute_margin,
- store=_margin_triggers,
- method=True,
- string='Theorical Margin (%)',
- digits_compute=dp.get_precision('Sale Price'),
- multi='margin',
- help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] '
- 'of the product form (not based on historical values).'
- 'Take care of tax include and exclude.. If no sale price '
- 'set, will display 999.0'),
- }
+ standard_margin_rate = fields.Float(
+ compute=_get_margin, string='Theorical Margin (%)', store=True,
+ digits_compute=dp.get_precision('Product Margin Precision'),
+ help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] '
+ 'of the product form (not based on historical values).'
+ 'Take care of tax include and exclude.. If no sale price '
+ 'set, will display 999.0')
diff --git a/product_standard_margin/views/view.xml b/product_standard_margin/views/view.xml
index 07cfa3135..eaeba8280 100644
--- a/product_standard_margin/views/view.xml
+++ b/product_standard_margin/views/view.xml
@@ -1,20 +1,19 @@
-
-
- product.markup.view.form
- form
- product.product
-
-
-
-
-
-
-
-
-
-
+
+
+
+ product.product
+
+
+
+
+
+
+
+
+
+
-
+
From 5a12d237f87226c20c4336a37baac7c8fd789122 Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Mon, 17 Aug 2015 12:03:41 +0200
Subject: [PATCH 28/80] [FIX] flake8 + Pylint;
---
product_standard_margin/models/product_product.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 657e1f879..01372f8b4 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -35,12 +35,11 @@ class ProductProduct(Model):
'taxes_id.price_include', 'taxes_id.amount',
'taxes_id.include_base_amount', 'taxes_id.child_depend')
def _get_margin(self):
- print "_get_margin"
tax_obj = self.pool['account.tax']
for product in self:
product.list_price_vat_excl = tax_obj.compute_all(
self.env.cr, self.env.uid, product.taxes_id,
- product.list_price, 1, product=product.id)['total']
+ product.list_price, 1, product=product.id)['total']
product.standard_margin =\
product.list_price_vat_excl - product.replenishment_cost
@@ -48,7 +47,8 @@ def _get_margin(self):
product.standard_margin_rate = 999.
else:
product.standard_margin_rate = (
- (product.list_price_vat_excl - product.replenishment_cost) /
+ (product.list_price_vat_excl
+ - product.replenishment_cost) /
product.list_price_vat_excl * 100)
# Column Section
From 3e30764352332a38527c756ced52c05842795d4d Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Mon, 17 Aug 2015 17:54:27 +0200
Subject: [PATCH 29/80] [REF] use new API;
---
product_standard_margin/models/product_product.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 01372f8b4..6ddb14d3d 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -35,10 +35,8 @@ class ProductProduct(Model):
'taxes_id.price_include', 'taxes_id.amount',
'taxes_id.include_base_amount', 'taxes_id.child_depend')
def _get_margin(self):
- tax_obj = self.pool['account.tax']
for product in self:
- product.list_price_vat_excl = tax_obj.compute_all(
- self.env.cr, self.env.uid, product.taxes_id,
+ product.list_price_vat_excl = product.taxes_id.compute_all(
product.list_price, 1, product=product.id)['total']
product.standard_margin =\
From 4a605b9e947df454785623bf34c5211990956194 Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Mon, 17 Aug 2015 17:57:43 +0200
Subject: [PATCH 30/80] [REF] add AGPL logo;
---
product_standard_margin/README.rst | 3 +++
1 file changed, 3 insertions(+)
diff --git a/product_standard_margin/README.rst b/product_standard_margin/README.rst
index 1c5c9e351..abaf29e09 100644
--- a/product_standard_margin/README.rst
+++ b/product_standard_margin/README.rst
@@ -1,3 +1,6 @@
+.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
+ :alt: License: AGPL-3
+
Product Margin and Margin Rate
==============================
From 526eab3b348cff3f2ea54848cb720db3ad5003f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Bidoul?=
Date: Fri, 9 Oct 2015 10:01:49 +0200
Subject: [PATCH 31/80] [UPD] prefix versions with 8.0
---
product_standard_margin/__openerp__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index 5db420157..d523b73f5 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -20,7 +20,7 @@
##############################################################################
{
'name': 'Product Margin and Margin Rate',
- 'version': '2.0',
+ 'version': '8.0.2.0.0',
'author': 'Camptocamp,GRAP,Odoo Community Association (OCA)',
'category': 'Product',
'depends': [
From 79306aaa32cfc54df4b59acebcf2748c50d7e9ad Mon Sep 17 00:00:00 2001
From: "Pedro M. Baeza"
Date: Wed, 14 Oct 2015 03:30:30 +0200
Subject: [PATCH 32/80] [MIG] Make modules uninstallable
---
product_standard_margin/__openerp__.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__openerp__.py
index d523b73f5..845100e4d 100644
--- a/product_standard_margin/__openerp__.py
+++ b/product_standard_margin/__openerp__.py
@@ -33,4 +33,5 @@
'views/view.xml',
],
'license': 'AGPL-3',
+ 'installable': False,
}
From 7eaf234916128fb8d4fc3f781fc38cfa47390423 Mon Sep 17 00:00:00 2001
From: "Pedro M. Baeza"
Date: Thu, 6 Oct 2016 15:56:23 +0200
Subject: [PATCH 33/80] [MIG] Rename manifest files
---
product_standard_margin/{__openerp__.py => __manifest__.py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename product_standard_margin/{__openerp__.py => __manifest__.py} (100%)
diff --git a/product_standard_margin/__openerp__.py b/product_standard_margin/__manifest__.py
similarity index 100%
rename from product_standard_margin/__openerp__.py
rename to product_standard_margin/__manifest__.py
From 2116332607807d24a0613f5c9b7c714ea5419a06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?=
Date: Fri, 15 Jun 2018 23:32:06 +0200
Subject: [PATCH 34/80] remove obsolete .pot files [ci skip]
---
.../i18n/product_standard_margin.pot | 44 -------------------
1 file changed, 44 deletions(-)
delete mode 100644 product_standard_margin/i18n/product_standard_margin.pot
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
deleted file mode 100644
index 264b76eda..000000000
--- a/product_standard_margin/i18n/product_standard_margin.pot
+++ /dev/null
@@ -1,44 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * product_standard_margin
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 7.0\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-10-14 18:35+0000\n"
-"PO-Revision-Date: 2013-10-14 18:35+0000\n"
-"Last-Translator: <>\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: \n"
-"Plural-Forms: \n"
-
-#. module: product_standard_margin
-#: help:product.product,standard_margin_rate:0
-msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model,name:product_standard_margin.model_product_product
-msgid "Product"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin_rate
-#: field:product.product,standard_margin_rate:0
-msgid "Theorical Margin (%)"
-msgstr ""
-
-#. module: product_standard_margin
-#: help:product.product,standard_margin:0
-msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin
-#: field:product.product,standard_margin:0
-msgid "Theorical Margin"
-msgstr ""
-
From 8050195bb98a7dbf1188c9df231d0bade497063f Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Tue, 7 Jan 2020 12:36:25 +0100
Subject: [PATCH 35/80] [REF] product_standard_margin: Black python code
---
product_standard_margin/__manifest__.py | 24 +++----
.../models/product_product.py | 66 ++++++++++++-------
2 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/product_standard_margin/__manifest__.py b/product_standard_margin/__manifest__.py
index 845100e4d..f1de21b6f 100644
--- a/product_standard_margin/__manifest__.py
+++ b/product_standard_margin/__manifest__.py
@@ -19,19 +19,13 @@
#
##############################################################################
{
- 'name': 'Product Margin and Margin Rate',
- 'version': '8.0.2.0.0',
- 'author': 'Camptocamp,GRAP,Odoo Community Association (OCA)',
- 'category': 'Product',
- 'depends': [
- 'product_replenishment_cost',
- 'account',
- ],
- 'website': 'http://www.camptocamp.com/',
- 'data': [
- 'data/decimal_precision.yml',
- 'views/view.xml',
- ],
- 'license': 'AGPL-3',
- 'installable': False,
+ "name": "Product Margin and Margin Rate",
+ "version": "8.0.2.0.0",
+ "author": "Camptocamp,GRAP,Odoo Community Association (OCA)",
+ "category": "Product",
+ "depends": ["product_replenishment_cost", "account",],
+ "website": "http://www.camptocamp.com/",
+ "data": ["data/decimal_precision.yml", "views/view.xml",],
+ "license": "AGPL-3",
+ "installable": False,
}
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 6ddb14d3d..7a6a6f257 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -27,46 +27,62 @@
class ProductProduct(Model):
- _inherit = 'product.product'
+ _inherit = "product.product"
@api.multi
@api.depends(
- 'product_tmpl_id.list_price', 'replenishment_cost', 'taxes_id.type',
- 'taxes_id.price_include', 'taxes_id.amount',
- 'taxes_id.include_base_amount', 'taxes_id.child_depend')
+ "product_tmpl_id.list_price",
+ "replenishment_cost",
+ "taxes_id.type",
+ "taxes_id.price_include",
+ "taxes_id.amount",
+ "taxes_id.include_base_amount",
+ "taxes_id.child_depend",
+ )
def _get_margin(self):
for product in self:
product.list_price_vat_excl = product.taxes_id.compute_all(
- product.list_price, 1, product=product.id)['total']
+ product.list_price, 1, product=product.id
+ )["total"]
- product.standard_margin =\
+ product.standard_margin = (
product.list_price_vat_excl - product.replenishment_cost
+ )
if product.list_price_vat_excl == 0:
- product.standard_margin_rate = 999.
+ product.standard_margin_rate = 999.0
else:
product.standard_margin_rate = (
- (product.list_price_vat_excl
- - product.replenishment_cost) /
- product.list_price_vat_excl * 100)
+ (product.list_price_vat_excl - product.replenishment_cost)
+ / product.list_price_vat_excl
+ * 100
+ )
# Column Section
list_price_vat_excl = fields.Float(
- compute=_get_margin, string='Sale Price VAT Excluded', store=True,
- digits_compute=dp.get_precision('Product Price'),
- )
+ compute=_get_margin,
+ string="Sale Price VAT Excluded",
+ store=True,
+ digits_compute=dp.get_precision("Product Price"),
+ )
standard_margin = fields.Float(
- compute=_get_margin, string='Theorical Margin', store=True,
- digits_compute=dp.get_precision('Product Price'),
- help='Theorical Margin is [ sale price (Wo Tax) - cost price ] '
- 'of the product form (not based on historical values). '
- 'Take care of tax include and exclude. If no sale price, '
- 'the margin will be negativ.')
+ compute=_get_margin,
+ string="Theorical Margin",
+ store=True,
+ digits_compute=dp.get_precision("Product Price"),
+ help="Theorical Margin is [ sale price (Wo Tax) - cost price ] "
+ "of the product form (not based on historical values). "
+ "Take care of tax include and exclude. If no sale price, "
+ "the margin will be negativ.",
+ )
standard_margin_rate = fields.Float(
- compute=_get_margin, string='Theorical Margin (%)', store=True,
- digits_compute=dp.get_precision('Product Margin Precision'),
- help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] '
- 'of the product form (not based on historical values).'
- 'Take care of tax include and exclude.. If no sale price '
- 'set, will display 999.0')
+ compute=_get_margin,
+ string="Theorical Margin (%)",
+ store=True,
+ digits_compute=dp.get_precision("Product Margin Precision"),
+ help="Markup rate is [ Theorical Margin / sale price (Wo Tax) ] "
+ "of the product form (not based on historical values)."
+ "Take care of tax include and exclude.. If no sale price "
+ "set, will display 999.0",
+ )
From ab81ff8902deec4b87651af3fd8ae4a745e5da84 Mon Sep 17 00:00:00 2001
From: Sylvain LE GAL
Date: Tue, 7 Jan 2020 12:36:25 +0100
Subject: [PATCH 36/80] [MIG] product_standard_margin: Migration to 12.0 [IMP]
compute and display margin fields on template [REF] OCA Convention: readme
files, etc. [IMP] Add tests
---
product_standard_margin/__init__.py | 21 ----
product_standard_margin/__manifest__.py | 37 +++----
.../data/decimal_precision.yml | 24 -----
product_standard_margin/i18n/fr.po | 64 +++++------
product_standard_margin/models/__init__.py | 21 +---
.../models/product_product.py | 100 +++++++-----------
.../models/product_template.py | 67 ++++++++++++
.../readme/CONTRIBUTORS.rst | 4 +
.../readme/DESCRIPTION.rst | 17 +++
product_standard_margin/readme/ROADMAP.rst | 7 ++
.../static/description/product_form.png | Bin 0 -> 16078 bytes
product_standard_margin/tests/__init__.py | 1 +
product_standard_margin/tests/test_module.py | 57 ++++++++++
product_standard_margin/views/view.xml | 19 ----
.../views/view_product_product.xml | 32 ++++++
.../views/view_product_template.xml | 16 +++
16 files changed, 287 insertions(+), 200 deletions(-)
delete mode 100644 product_standard_margin/data/decimal_precision.yml
create mode 100644 product_standard_margin/models/product_template.py
create mode 100644 product_standard_margin/readme/CONTRIBUTORS.rst
create mode 100644 product_standard_margin/readme/DESCRIPTION.rst
create mode 100644 product_standard_margin/readme/ROADMAP.rst
create mode 100644 product_standard_margin/static/description/product_form.png
create mode 100644 product_standard_margin/tests/__init__.py
create mode 100644 product_standard_margin/tests/test_module.py
delete mode 100644 product_standard_margin/views/view.xml
create mode 100644 product_standard_margin/views/view_product_product.xml
create mode 100644 product_standard_margin/views/view_product_template.xml
diff --git a/product_standard_margin/__init__.py b/product_standard_margin/__init__.py
index cb1a1975c..0650744f6 100644
--- a/product_standard_margin/__init__.py
+++ b/product_standard_margin/__init__.py
@@ -1,22 +1 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
from . import models
diff --git a/product_standard_margin/__manifest__.py b/product_standard_margin/__manifest__.py
index f1de21b6f..6b59657dd 100644
--- a/product_standard_margin/__manifest__.py
+++ b/product_standard_margin/__manifest__.py
@@ -1,31 +1,18 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# Copyright (C) 2012 - Today: Camptocamp SA
+# @author: Joel Grand-Guillaume
+# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
+# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Product Margin and Margin Rate",
- "version": "8.0.2.0.0",
+ "version": "12.0.1.0.0",
"author": "Camptocamp,GRAP,Odoo Community Association (OCA)",
"category": "Product",
- "depends": ["product_replenishment_cost", "account",],
- "website": "http://www.camptocamp.com/",
- "data": ["data/decimal_precision.yml", "views/view.xml",],
+ "depends": ["account"],
+ "maintainers": ["legalsylvain"],
+ "website": "https://www.github.com/OCA/margin-analysis",
+ "data": ["views/view_product_product.xml", "views/view_product_template.xml"],
"license": "AGPL-3",
- "installable": False,
+ "installable": True,
+ "images": ["static/description/product_form.png"],
}
diff --git a/product_standard_margin/data/decimal_precision.yml b/product_standard_margin/data/decimal_precision.yml
deleted file mode 100644
index c96bcc573..000000000
--- a/product_standard_margin/data/decimal_precision.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (C) 2015-Today GRAP (http://www.grap.coop)
-# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-- !record {model: decimal.precision, id: product_margin_precision}:
- name: Product Margin Precision
- digits: 2
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
index 228f7994f..c9b621929 100644
--- a/product_standard_margin/i18n/fr.po
+++ b/product_standard_margin/i18n/fr.po
@@ -1,57 +1,59 @@
-# Translation of OpenERP Server.
+# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * product_standard_margin
+# * product_standard_margin
#
msgid ""
msgstr ""
-"Project-Id-Version: OpenERP Server 7.0\n"
+"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-10-14 18:35+0000\n"
-"PO-Revision-Date: 2012-11-07 14:35+0000\n"
+"POT-Creation-Date: 2020-01-07 14:51+0000\n"
+"PO-Revision-Date: 2020-01-07 14:51+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
-"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: product_standard_margin
-#: help:product.product,standard_margin_rate:0
-msgid ""
-"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.. "
-"If no sale price set, will display 999.0"
-msgstr ""
-"Taux de marge théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
-"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
-"taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le "
-"taux sera de 999.0"
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr "Taux de marque théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du formulaire Produit] (ne tient pas compte de la facturation effective). Ce taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le taux sera de 999.0"
#. module: product_standard_margin
#: model:ir.model,name:product_standard_margin.model_product_product
msgid "Product"
-msgstr "Produit"
+msgstr "Article"
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_template
+msgid "Product Template"
+msgstr "Modèle d'article"
#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin_rate
-#: field:product.product,standard_margin_rate:0
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__list_price_vat_excl
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__list_price_vat_excl
+msgid "Sale Price VAT Excluded"
+msgstr "Prix de vente (HT)"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin"
+msgstr "Marge Théorique"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin_rate
msgid "Theorical Margin (%)"
-msgstr "Marge Théorique (%)"
+msgstr "Taux de marque Théorique (%)"
#. module: product_standard_margin
-#: help:product.product,standard_margin:0
-msgid ""
-"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
-"(not based on historical values). Take care of tax include and exclude. If "
-"no sale price, the margin will be negativ."
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
msgstr ""
"Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient "
"pas compte de la facturation effective). Ce taux tient compte des PV TTC "
"(TVA incluse). Si aucun PV n'a été saisi, la marge sera négative."
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product_standard_margin
-#: field:product.product,standard_margin:0
-msgid "Theorical Margin"
-msgstr "Marge Théorique"
diff --git a/product_standard_margin/models/__init__.py b/product_standard_margin/models/__init__.py
index 8d4366b62..18b37e853 100644
--- a/product_standard_margin/models/__init__.py
+++ b/product_standard_margin/models/__init__.py
@@ -1,21 +1,2 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Author: Joel Grand-Guillaume
-# Copyright 2012 Camptocamp SA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
from . import product_product
+from . import product_template
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 7a6a6f257..3e74258f5 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -1,75 +1,29 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2012 Camptocamp SA (http://www.camptocamp.com)
-# All Right Reserved
-#
-# Author : Joel Grand-Guillaume
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
+# Copyright (C) 2012 - Today: Camptocamp SA
+# @author: Joel Grand-Guillaume
+# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
+# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from openerp import fields, api
-from openerp.models import Model
-import openerp.addons.decimal_precision as dp
+from odoo import api, fields, models
+import odoo.addons.decimal_precision as dp
-class ProductProduct(Model):
+class ProductProduct(models.Model):
_inherit = "product.product"
- @api.multi
- @api.depends(
- "product_tmpl_id.list_price",
- "replenishment_cost",
- "taxes_id.type",
- "taxes_id.price_include",
- "taxes_id.amount",
- "taxes_id.include_base_amount",
- "taxes_id.child_depend",
- )
- def _get_margin(self):
- for product in self:
- product.list_price_vat_excl = product.taxes_id.compute_all(
- product.list_price, 1, product=product.id
- )["total"]
-
- product.standard_margin = (
- product.list_price_vat_excl - product.replenishment_cost
- )
- if product.list_price_vat_excl == 0:
- product.standard_margin_rate = 999.0
- else:
- product.standard_margin_rate = (
- (product.list_price_vat_excl - product.replenishment_cost)
- / product.list_price_vat_excl
- * 100
- )
-
# Column Section
list_price_vat_excl = fields.Float(
- compute=_get_margin,
+ compute="_compute_margin",
string="Sale Price VAT Excluded",
store=True,
- digits_compute=dp.get_precision("Product Price"),
+ digits=dp.get_precision("Product Price"),
)
standard_margin = fields.Float(
- compute=_get_margin,
+ compute="_compute_margin",
string="Theorical Margin",
store=True,
- digits_compute=dp.get_precision("Product Price"),
+ digits=dp.get_precision("Product Price"),
help="Theorical Margin is [ sale price (Wo Tax) - cost price ] "
"of the product form (not based on historical values). "
"Take care of tax include and exclude. If no sale price, "
@@ -77,12 +31,38 @@ def _get_margin(self):
)
standard_margin_rate = fields.Float(
- compute=_get_margin,
+ compute="_compute_margin",
string="Theorical Margin (%)",
store=True,
- digits_compute=dp.get_precision("Product Margin Precision"),
+ digits=dp.get_precision("Product Price"),
help="Markup rate is [ Theorical Margin / sale price (Wo Tax) ] "
"of the product form (not based on historical values)."
"Take care of tax include and exclude.. If no sale price "
"set, will display 999.0",
)
+
+ # Compute Section
+ @api.depends(
+ "lst_price",
+ "product_tmpl_id.list_price",
+ "standard_price",
+ "taxes_id.price_include",
+ "taxes_id.amount",
+ "taxes_id.include_base_amount",
+ )
+ def _compute_margin(self):
+ for product in self:
+ product.list_price_vat_excl = product.taxes_id.compute_all(
+ product.lst_price, product=product
+ )["total_excluded"]
+ product.standard_margin = (
+ product.list_price_vat_excl - product.standard_price
+ )
+ if product.list_price_vat_excl == 0:
+ product.standard_margin_rate = 999.0
+ else:
+ product.standard_margin_rate = (
+ (product.list_price_vat_excl - product.standard_price)
+ / product.list_price_vat_excl
+ * 100
+ )
diff --git a/product_standard_margin/models/product_template.py b/product_standard_margin/models/product_template.py
new file mode 100644
index 000000000..19e1f2a1a
--- /dev/null
+++ b/product_standard_margin/models/product_template.py
@@ -0,0 +1,67 @@
+# Copyright (C) 2012 - Today: Camptocamp SA
+# @author: Joel Grand-Guillaume
+# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
+# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import api, fields, models
+import odoo.addons.decimal_precision as dp
+
+
+class ProductTemplate(models.Model):
+ _inherit = "product.template"
+
+ # Column Section
+ list_price_vat_excl = fields.Float(
+ compute="_compute_margin",
+ string="Sale Price VAT Excluded",
+ digits=dp.get_precision("Product Price"),
+ )
+
+ standard_margin = fields.Float(
+ compute="_compute_margin",
+ string="Theorical Margin",
+ digits=dp.get_precision("Product Price"),
+ help="Theorical Margin is [ sale price (Wo Tax) - cost price ] "
+ "of the product form (not based on historical values). "
+ "Take care of tax include and exclude. If no sale price, "
+ "the margin will be negativ.",
+ )
+
+ standard_margin_rate = fields.Float(
+ compute="_compute_margin",
+ string="Theorical Margin (%)",
+ digits=dp.get_precision("Product Price"),
+ help="Margin rate is [ Theorical Margin / sale price (Wo Tax) ] "
+ "of the product form (not based on historical values)."
+ "Take care of tax include and exclude.. If no sale price "
+ "set, will display 999.0",
+ )
+
+ # Compute Section
+ @api.depends(
+ "lst_price",
+ "standard_price",
+ "taxes_id.price_include",
+ "taxes_id.amount",
+ "taxes_id.include_base_amount",
+ )
+ def _compute_margin(self):
+ # The code is duplicated from product.product model
+ # because otherwise, the recomputation is not done correctly
+ # when the product datas are changed from the template view
+ for template in self:
+ template.list_price_vat_excl = template.taxes_id.compute_all(
+ template.list_price, product=template
+ )["total_excluded"]
+ template.standard_margin = (
+ template.list_price_vat_excl - template.standard_price
+ )
+ if template.list_price_vat_excl == 0:
+ template.standard_margin_rate = 999.0
+ else:
+ template.standard_margin_rate = (
+ (template.list_price_vat_excl - template.standard_price)
+ / template.list_price_vat_excl
+ * 100
+ )
diff --git a/product_standard_margin/readme/CONTRIBUTORS.rst b/product_standard_margin/readme/CONTRIBUTORS.rst
new file mode 100644
index 000000000..1e1d54b12
--- /dev/null
+++ b/product_standard_margin/readme/CONTRIBUTORS.rst
@@ -0,0 +1,4 @@
+* Alexandre Fayolle
+* Yannick Vaucher
+* Joël Grand-Guillaume
+* Sylvain Le Gal (https://twitter.com/legalsylvain)
diff --git a/product_standard_margin/readme/DESCRIPTION.rst b/product_standard_margin/readme/DESCRIPTION.rst
new file mode 100644
index 000000000..3698a5682
--- /dev/null
+++ b/product_standard_margin/readme/DESCRIPTION.rst
@@ -0,0 +1,17 @@
+Add a field on the product form that compute the standard (or theorical)
+margin based on the current values of sale and standard price present in
+the product form. We take care of taxe included or excluded.
+
+It will just compute it as follow:
+(Sale Price without tax - Standard Price) / Sale Price without tax
+
+.. figure:: ../static/description/product_form.png
+
+**Note:**
+
+As this module will base his simple computation on sale and cost prices,
+it suppose you have them both in the same currency (the price type must of
+the same currency for both of them). Remember this is the default OpenERP
+configuration (price type of all product price fields are set as the same as
+the company currency). We don't take care of it cause otherwise we should
+have added a dependency on sale module.
diff --git a/product_standard_margin/readme/ROADMAP.rst b/product_standard_margin/readme/ROADMAP.rst
new file mode 100644
index 000000000..c711b0f1b
--- /dev/null
+++ b/product_standard_margin/readme/ROADMAP.rst
@@ -0,0 +1,7 @@
+* This module will not work properly if used in a multicompany context with product
+ prices depending on the company.
+
+* It should be great to use the odoo widget ``percentpie`` for the display of the
+ field ``standard_margin_rate`` but for the time being, the field is not displayed
+ properly.
+ Ref of the Odoo Issue: https://github.com/odoo/odoo/issues/42869
diff --git a/product_standard_margin/static/description/product_form.png b/product_standard_margin/static/description/product_form.png
new file mode 100644
index 0000000000000000000000000000000000000000..bd8146a0daace0d58b50f73f97b6d48fe41d7b31
GIT binary patch
literal 16078
zcmcJ0WmH^Ew`L>3fGZ
z&fxSp$PbhlU8V>4Bfg8Iri+@rxr@7zlNrF>-JRLW&f3|;$ia-+-pL~KRDb{gAOpxs
zh<^6SI$rTt`0Sqd_O{n{5R;0`sX)PAGP?4O6(l}wMOomORQXpi%+^qC-7TBu>r{8~
zd-FaQ^0hDC42pqL$6uE1JEd$wZl%nE!mCiWLirfII~%GUyoKCy@gQ@t+(?QskolWSOL+`X`4BK`1OF2Zn6^
z|BFhldYv>xOj$P^@LE>^(Fh6>t2LsYaUb~~{!05Z5FW=hK7!J0j|9h}^9pE%U&@!Hw4eX)JoCTmoBK)jUy?0Ox0%1t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e`Nh_Q)J*|{O9rnZ6u$`a)pmydA7u3%I0|G8CY*#E6d}f5tQgpzXIWFY-R-`&2!C|nen*uK%YSE`q}L7Bf(
z>pktQGy4bU({m@-QIU=*`&dPXO28`JJ-nL5&7G+hshYgU00i&n^BSAS8@zuvR%v5+t}{?rkYBkZ-;ERkOdD-~k@vWpM;*X3#ayo`Up
ykp1g^br{`$Tt+5G`qzCE(}@3>_upBbQCY{z-a*lN%Y*Nt17szYBr3!VgZ>AbhYhj-
literal 0
HcmV?d00001
diff --git a/product_standard_margin/tests/__init__.py b/product_standard_margin/tests/__init__.py
new file mode 100644
index 000000000..d9b96c4fa
--- /dev/null
+++ b/product_standard_margin/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_module
diff --git a/product_standard_margin/tests/test_module.py b/product_standard_margin/tests/test_module.py
new file mode 100644
index 000000000..af7d103e2
--- /dev/null
+++ b/product_standard_margin/tests/test_module.py
@@ -0,0 +1,57 @@
+# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
+# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo.tests.common import TransactionCase
+
+
+class TestModule(TransactionCase):
+
+ def setUp(self):
+ super().setUp()
+ self.ProductProduct = self.env['product.product']
+ self.ProductTemplate = self.env['product.template']
+
+ # Custom Section
+ def _create_product(self, model, standard_price, sale_price, sale_tax_ids):
+ if model == 'product':
+ ModelObj = self.ProductProduct
+ else:
+ ModelObj = self.ProductTemplate
+ return ModelObj.create({
+ 'name': 'Demo Product',
+ 'standard_price': standard_price,
+ 'lst_price': sale_price,
+ 'taxes_id': [(6, 0, sale_tax_ids)],
+ })
+
+ # Test Section
+ def test_01_classic_margin(self):
+ for model in ['product', 'template']:
+ product = self._create_product(model, 50, 200, [])
+ self.assertEqual(
+ product.standard_margin, 150,
+ "Incorrect Standard Margin")
+ self.assertEqual(
+ product.standard_margin_rate, 75.0,
+ "Incorrect Standard Margin Rate")
+
+ def test_02_margin_without_standard_price(self):
+ for model in ['product', 'template']:
+ product = self._create_product(model, 0, 200, [])
+ self.assertEqual(
+ product.standard_margin, 200,
+ "Incorrect Standard Margin (without standard price)")
+ self.assertEqual(
+ product.standard_margin_rate, 100.0,
+ "Incorrect Standard Margin Rate (without standard price)")
+
+ def test_03_margin_without_sale_price(self):
+ for model in ['product', 'template']:
+ product = self._create_product(model, 50, 0, [])
+ self.assertEqual(
+ product.standard_margin, -50,
+ "Incorrect Standard Margin (without sale price)")
+ self.assertEqual(
+ product.standard_margin_rate, 999.0,
+ "Incorrect Standard Margin Rate (without sale price)")
diff --git a/product_standard_margin/views/view.xml b/product_standard_margin/views/view.xml
deleted file mode 100644
index eaeba8280..000000000
--- a/product_standard_margin/views/view.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- product.product
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/product_standard_margin/views/view_product_product.xml b/product_standard_margin/views/view_product_product.xml
new file mode 100644
index 000000000..2e1df3e90
--- /dev/null
+++ b/product_standard_margin/views/view_product_product.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ product.product
+
+
+
+
+
+
+
+
+
+
+
+
+
+ product.product
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/product_standard_margin/views/view_product_template.xml b/product_standard_margin/views/view_product_template.xml
new file mode 100644
index 000000000..da68bdd01
--- /dev/null
+++ b/product_standard_margin/views/view_product_template.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ product.template
+
+
+
+
+
+
+
+
+
From d5267d67ba4e6a34656ae5818fa30eb25aa4f514 Mon Sep 17 00:00:00 2001
From: oca-travis
Date: Sun, 19 Jul 2020 08:36:41 +0000
Subject: [PATCH 37/80] [UPD] Update product_standard_margin.pot
---
product_standard_margin/i18n/fr.po | 33 +++++++--
product_standard_margin/i18n/nl.po | 72 +++++++++++++------
.../i18n/product_standard_margin.pot | 59 +++++++++++++++
3 files changed, 136 insertions(+), 28 deletions(-)
create mode 100644 product_standard_margin/i18n/product_standard_margin.pot
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
index c9b621929..b168fe40c 100644
--- a/product_standard_margin/i18n/fr.po
+++ b/product_standard_margin/i18n/fr.po
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * product_standard_margin
+# * product_standard_margin
#
msgid ""
msgstr ""
@@ -10,16 +10,36 @@ msgstr ""
"PO-Revision-Date: 2020-01-07 14:51+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: product_standard_margin
-#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
-msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
-msgstr "Taux de marque théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du formulaire Produit] (ne tient pas compte de la facturation effective). Ce taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le taux sera de 999.0"
+msgid ""
+"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+"Taux de marque théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
+"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
+"taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le "
+"taux sera de 999.0"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
+#, fuzzy
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+"Taux de marque théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
+"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
+"taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le "
+"taux sera de 999.0"
#. module: product_standard_margin
#: model:ir.model,name:product_standard_margin.model_product_product
@@ -52,7 +72,10 @@ msgstr "Taux de marque Théorique (%)"
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
-msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values). Take care of tax include and exclude. If "
+"no sale price, the margin will be negativ."
msgstr ""
"Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient "
"pas compte de la facturation effective). Ce taux tient compte des PV TTC "
diff --git a/product_standard_margin/i18n/nl.po b/product_standard_margin/i18n/nl.po
index 554bdeb5a..0cc539b5b 100644
--- a/product_standard_margin/i18n/nl.po
+++ b/product_standard_margin/i18n/nl.po
@@ -11,6 +11,7 @@ msgstr ""
"Last-Translator: Erwin van der Ploeg | Endian Solutions "
"\n"
"Language-Team: \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -18,17 +19,20 @@ msgstr ""
"X-Generator: Poedit 1.5.4\n"
#. module: product_standard_margin
-#: model:ir.model,name:product_standard_margin.model_product_product
-msgid "Product"
-msgstr "Product"
-
-#. module: product_standard_margin
-#: field:product.product,standard_margin_rate:0
-msgid "Theorical Margin (%)"
-msgstr "Theoretische marge (%)"
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
+#, fuzzy
+msgid ""
+"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+"Theoretische marge (%) is [ Theoretische marge / Verkoopprijs (excl. BTW) ] "
+"van het product (niet gebaseerd op historische waardes). Het veld houdt "
+"rekening met prijzen incl. en excl. BTW. Indien geen verkooprijs is "
+"ingevoerd, wordt 999,0 weergegeven."
#. module: product_standard_margin
-#: help:product.product,standard_margin_rate:0
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
msgid ""
"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
"form (not based on historical values).Take care of tax include and exclude.. "
@@ -40,28 +44,50 @@ msgstr ""
"ingevoerd, wordt 999,0 weergegeven."
#. module: product_standard_margin
-#: constraint:product.product:0
-msgid "Error: Invalid ean code"
-msgstr "Fout: ongeldige ean code"
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr "Product"
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_template
+#, fuzzy
+msgid "Product Template"
+msgstr "Product"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__list_price_vat_excl
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__list_price_vat_excl
+msgid "Sale Price VAT Excluded"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin"
+msgstr "Theoretische marge"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Theorical Margin (%)"
+msgstr "Theoretische marge (%)"
#. module: product_standard_margin
-#: help:product.product,standard_margin:0
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
+#, fuzzy
msgid ""
"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
-"(not based on historical values).Take care of tax include and exclude. If no "
-"sale price, the margin will be negativ."
+"(not based on historical values). Take care of tax include and exclude. If "
+"no sale price, the margin will be negativ."
msgstr ""
"Theoretische marge is [ Verkoopprijs (excl. BTW) - Kostprijs) ] van het "
"product (niet gebaseerd op historische waardes). Het veld houdt rekening met "
"prijzen incl. en excl. BTW. Indien geen verkooprijs is ingevoerd, zal de "
"marge negatief zijn."
-#. module: product_standard_margin
-#: view:product.product:0
-msgid "Margin"
-msgstr "Marge"
+#~ msgid "Error: Invalid ean code"
+#~ msgstr "Fout: ongeldige ean code"
-#. module: product_standard_margin
-#: field:product.product,standard_margin:0
-msgid "Theorical Margin"
-msgstr "Theoretische marge"
+#~ msgid "Margin"
+#~ msgstr "Marge"
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
new file mode 100644
index 000000000..fdd3b6056
--- /dev/null
+++ b/product_standard_margin/i18n/product_standard_margin.pot
@@ -0,0 +1,59 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
+msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_template
+msgid "Product Template"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__list_price_vat_excl
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__list_price_vat_excl
+msgid "Sale Price VAT Excluded"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Theorical Margin (%)"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgstr ""
+
From 28415e79bd4fd14a676acf42f5c58ac9fb8b559d Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Sun, 19 Jul 2020 08:47:38 +0000
Subject: [PATCH 38/80] [UPD] README.rst
---
product_standard_margin/README.rst | 108 +++--
.../static/description/index.html | 451 ++++++++++++++++++
2 files changed, 532 insertions(+), 27 deletions(-)
create mode 100644 product_standard_margin/static/description/index.html
diff --git a/product_standard_margin/README.rst b/product_standard_margin/README.rst
index abaf29e09..67f6efbd7 100644
--- a/product_standard_margin/README.rst
+++ b/product_standard_margin/README.rst
@@ -1,58 +1,112 @@
-.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
- :alt: License: AGPL-3
-
+==============================
Product Margin and Margin Rate
==============================
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
+ :target: https://odoo-community.org/page/development-status
+ :alt: Beta
+.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
+.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmargin--analysis-lightgray.png?logo=github
+ :target: https://github.com/OCA/margin-analysis/tree/12.0/product_standard_margin
+ :alt: OCA/margin-analysis
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/margin-analysis-12-0/margin-analysis-12-0-product_standard_margin
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/132/12.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
Add a field on the product form that compute the standard (or theorical)
-margin based on the current values of sale and replenishment cost present in
+margin based on the current values of sale and standard price present in
the product form. We take care of taxe included or excluded.
It will just compute it as follow:
-(Sale Price without tax - Replenishment Cost) / Sale Price without tax
+(Sale Price without tax - Standard Price) / Sale Price without tax
+
+.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/12.0/product_standard_margin/static/description/product_form.png
+
+**Note:**
+
+As this module will base his simple computation on sale and cost prices,
+it suppose you have them both in the same currency (the price type must of
+the same currency for both of them). Remember this is the default OpenERP
+configuration (price type of all product price fields are set as the same as
+the company currency). We don't take care of it cause otherwise we should
+have added a dependency on sale module.
+
+**Table of contents**
-Remember that this module can be used in conjonction with
-product_cost_incl_bom to have the replenishment cost computed from the BOM when
-a product has one.
+.. contents::
+ :local:
- WARNING:
+Known issues / Roadmap
+======================
- 1) As this module will base his simple computation on sale and cost prices,
- it suppose you have them both in the same currency (the price type must of
- the same currency for both of them). Remember this is the default OpenERP
- configuration (price type of all product price fields are set as the same as
- the company currency). We don't take care of it cause otherwise we should
- have added a dependency on sale module.
+* This module will not work properly if used in a multicompany context with product
+ prices depending on the company.
+
+* It should be great to use the odoo widget ``percentpie`` for the display of the
+ field ``standard_margin_rate`` but for the time being, the field is not displayed
+ properly.
+ Ref of the Odoo Issue: https://github.com/odoo/odoo/issues/42869
Bug Tracker
===========
-Bugs are tracked on `GitHub Issues `_.
+Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
-If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
-`here `_.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+`feedback `_.
+
+Do not contact contributors directly about support or help with technical issues.
Credits
=======
+Authors
+~~~~~~~
+
+* Camptocamp
+* GRAP
+
Contributors
-------------
+~~~~~~~~~~~~
* Alexandre Fayolle
* Yannick Vaucher
* Joël Grand-Guillaume
* Sylvain Le Gal (https://twitter.com/legalsylvain)
-Maintainer
-----------
-
-.. image:: http://odoo-community.org/logo.png
- :alt: Odoo Community Association
- :target: http://odoo-community.org
+Maintainers
+~~~~~~~~~~~
This module is maintained by the OCA.
-OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
+.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
+ :target: https://github.com/legalsylvain
+ :alt: legalsylvain
+
+Current `maintainer `__:
+
+|maintainer-legalsylvain|
-To contribute to this module, please visit http://odoo-community.org.
+This module is part of the `OCA/margin-analysis `_ project on GitHub.
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/product_standard_margin/static/description/index.html b/product_standard_margin/static/description/index.html
new file mode 100644
index 000000000..184d8d251
--- /dev/null
+++ b/product_standard_margin/static/description/index.html
@@ -0,0 +1,451 @@
+
+
+
+
+
+
+Product Margin and Margin Rate
+
+
+
+
+
Product Margin and Margin Rate
+
+
+

+
Add a field on the product form that compute the standard (or theorical)
+margin based on the current values of sale and standard price present in
+the product form. We take care of taxe included or excluded.
+
It will just compute it as follow:
+(Sale Price without tax - Standard Price) / Sale Price without tax
+
+
Note:
+
As this module will base his simple computation on sale and cost prices,
+it suppose you have them both in the same currency (the price type must of
+the same currency for both of them). Remember this is the default OpenERP
+configuration (price type of all product price fields are set as the same as
+the company currency). We don’t take care of it cause otherwise we should
+have added a dependency on sale module.
+
Table of contents
+
+
+
+
+- This module will not work properly if used in a multicompany context with product
+prices depending on the company.
+- It should be great to use the odoo widget percentpie for the display of the
+field standard_margin_rate but for the time being, the field is not displayed
+properly.
+Ref of the Odoo Issue: https://github.com/odoo/odoo/issues/42869
+
+
+
+
+
Bugs are tracked on GitHub Issues.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+feedback.
+
Do not contact contributors directly about support or help with technical issues.
+
+
+
+
+
+
+
+
This module is maintained by the OCA.
+

+
OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
Current maintainer:
+

+
This module is part of the OCA/margin-analysis project on GitHub.
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+
+
+
+
+
From 438b645ffc8c61edd5cfec1ce1be4f19a66146ff Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Sun, 19 Jul 2020 08:47:39 +0000
Subject: [PATCH 39/80] [ADD] icon.png
---
.../static/description/icon.png | Bin 0 -> 9455 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 product_standard_margin/static/description/icon.png
diff --git a/product_standard_margin/static/description/icon.png b/product_standard_margin/static/description/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d
GIT binary patch
literal 9455
zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~!
zVpnB`o+K7|Al`Q_U;eD$B
zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA
z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__
zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_
zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I
z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U
z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)(
z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH
zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW
z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx
zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h
zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q9`ySe3%V$A*9
zeKEe+b0{#KWGp$F+tga)0RtI)nhMa-K@JS}2krK~n8v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UtkJiG{}
zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N
Xviia!U7SGha1wx#SCgwmn*{w2TRX*I
literal 0
HcmV?d00001
From ea98626b56cbd4a501e7e0fe4648fe9db9341594 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Volksdorf?=
Date: Fri, 20 Nov 2020 18:15:00 +0000
Subject: [PATCH 40/80] Added translation using Weblate (German)
---
product_standard_margin/i18n/de.po | 59 ++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 product_standard_margin/i18n/de.po
diff --git a/product_standard_margin/i18n/de.po b/product_standard_margin/i18n/de.po
new file mode 100644
index 000000000..5fc7044b9
--- /dev/null
+++ b/product_standard_margin/i18n/de.po
@@ -0,0 +1,59 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: Automatically generated\n"
+"Language-Team: none\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
+msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_template
+msgid "Product Template"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__list_price_vat_excl
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__list_price_vat_excl
+msgid "Sale Price VAT Excluded"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Theorical Margin (%)"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgstr ""
From 67fe5f62ab7d260a696a0f928632bd47a81b9608 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Volksdorf?=
Date: Fri, 20 Nov 2020 18:16:40 +0000
Subject: [PATCH 41/80] Translated using Weblate (German)
Currently translated at 100.0% (8 of 8 strings)
Translation: margin-analysis-12.0/margin-analysis-12.0-product_standard_margin
Translate-URL: https://translation.odoo-community.org/projects/margin-analysis-12-0/margin-analysis-12-0-product_standard_margin/de/
---
product_standard_margin/i18n/de.po | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/product_standard_margin/i18n/de.po b/product_standard_margin/i18n/de.po
index 5fc7044b9..1386c8ad9 100644
--- a/product_standard_margin/i18n/de.po
+++ b/product_standard_margin/i18n/de.po
@@ -6,54 +6,67 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2020-11-20 18:43+0000\n"
+"Last-Translator: André Volksdorf \n"
"Language-Team: none\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Weblate 3.10\n"
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
msgstr ""
+"Der Margensatz ist [ Theoretische Marge / Verkaufspreis (Ohne Steuern) ] des "
+"Produkts (nicht auf historischen Werten basierend), wobei darauf zu achten "
+"ist, Steuern ein- und auszuschließen. Wenn kein Verkaufspreis festgelegt "
+"wurde, wird 999.0 angezeigt"
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
msgstr ""
+"Der Aufschlagssatz ist [ Theoretische Marge / Verkaufspreis (Ohne Steuern) ] "
+"des Produkts (nicht auf historischen Werten basierend), mit und ohne Steuer. "
+"Wenn kein Verkaufspreis festgelegt wurde, wird 999.0 angezeigt"
#. module: product_standard_margin
#: model:ir.model,name:product_standard_margin.model_product_product
msgid "Product"
-msgstr ""
+msgstr "Produkt"
#. module: product_standard_margin
#: model:ir.model,name:product_standard_margin.model_product_template
msgid "Product Template"
-msgstr ""
+msgstr "Produktvorlage"
#. module: product_standard_margin
#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__list_price_vat_excl
#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__list_price_vat_excl
msgid "Sale Price VAT Excluded"
-msgstr ""
+msgstr "Verkaufspreis ohne Mehrwertsteuer"
#. module: product_standard_margin
#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin
msgid "Theorical Margin"
-msgstr ""
+msgstr "Theoretische Marge"
#. module: product_standard_margin
#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin_rate
#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin_rate
msgid "Theorical Margin (%)"
-msgstr ""
+msgstr "Theoretische Marge (%)"
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
msgstr ""
+"Theoretische Gewinnmarge ist [ Verkaufspreis (Ohne Steuern) - Einkaufspreis ]"
+" des Produkts (nicht auf historischen Werten basierend). Achten Sie darauf, "
+"Steuern ein- und auszuschließen. Wenn kein Verkaufspreis angegeben wird, ist "
+"die Marge negativ."
From 314924f46dd90755d272655f597a0ab6fc48037f Mon Sep 17 00:00:00 2001
From: Marcel Savegnago
Date: Sun, 14 Mar 2021 21:38:36 +0000
Subject: [PATCH 42/80] Added translation using Weblate (Portuguese (Brazil))
---
product_standard_margin/i18n/pt_BR.po | 59 +++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 product_standard_margin/i18n/pt_BR.po
diff --git a/product_standard_margin/i18n/pt_BR.po b/product_standard_margin/i18n/pt_BR.po
new file mode 100644
index 000000000..c8a043599
--- /dev/null
+++ b/product_standard_margin/i18n/pt_BR.po
@@ -0,0 +1,59 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: Automatically generated\n"
+"Language-Team: none\n"
+"Language: pt_BR\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: nplurals=2; plural=n > 1;\n"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
+msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_template
+msgid "Product Template"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__list_price_vat_excl
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__list_price_vat_excl
+msgid "Sale Price VAT Excluded"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Theorical Margin (%)"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgstr ""
From 81b1fd57c7bc54795ec59d652202866f7cc41e07 Mon Sep 17 00:00:00 2001
From: alvarorib
Date: Mon, 12 Apr 2021 13:56:36 +0000
Subject: [PATCH 43/80] Added translation using Weblate (Portuguese)
---
product_standard_margin/i18n/pt.po | 59 ++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 product_standard_margin/i18n/pt.po
diff --git a/product_standard_margin/i18n/pt.po b/product_standard_margin/i18n/pt.po
new file mode 100644
index 000000000..5be85e4ea
--- /dev/null
+++ b/product_standard_margin/i18n/pt.po
@@ -0,0 +1,59 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: Automatically generated\n"
+"Language-Team: none\n"
+"Language: pt\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: nplurals=2; plural=n > 1;\n"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
+msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_template
+msgid "Product Template"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__list_price_vat_excl
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__list_price_vat_excl
+msgid "Sale Price VAT Excluded"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Theorical Margin (%)"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgstr ""
From 8a23d8458a5f958f4ead44163a91508ab992ff39 Mon Sep 17 00:00:00 2001
From: Cyril VINH-TUNG
Date: Wed, 15 Dec 2021 11:46:34 -1000
Subject: [PATCH 44/80] [IMP] product_standard_margin: black, isort, prettier
---
product_standard_margin/__manifest__.py | 2 +-
.../models/product_product.py | 1 +
.../models/product_template.py | 1 +
product_standard_margin/tests/test_module.py | 59 +++++++++++--------
.../views/view_product_product.xml | 19 +++---
.../views/view_product_template.xml | 20 +++++--
6 files changed, 61 insertions(+), 41 deletions(-)
diff --git a/product_standard_margin/__manifest__.py b/product_standard_margin/__manifest__.py
index 6b59657dd..02c211f6d 100644
--- a/product_standard_margin/__manifest__.py
+++ b/product_standard_margin/__manifest__.py
@@ -10,7 +10,7 @@
"category": "Product",
"depends": ["account"],
"maintainers": ["legalsylvain"],
- "website": "https://www.github.com/OCA/margin-analysis",
+ "website": "https://github.com/OCA/margin-analysis",
"data": ["views/view_product_product.xml", "views/view_product_template.xml"],
"license": "AGPL-3",
"installable": True,
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 3e74258f5..5f3d52af7 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -5,6 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
+
import odoo.addons.decimal_precision as dp
diff --git a/product_standard_margin/models/product_template.py b/product_standard_margin/models/product_template.py
index 19e1f2a1a..8458feb98 100644
--- a/product_standard_margin/models/product_template.py
+++ b/product_standard_margin/models/product_template.py
@@ -5,6 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
+
import odoo.addons.decimal_precision as dp
diff --git a/product_standard_margin/tests/test_module.py b/product_standard_margin/tests/test_module.py
index af7d103e2..f628568bd 100644
--- a/product_standard_margin/tests/test_module.py
+++ b/product_standard_margin/tests/test_module.py
@@ -6,52 +6,59 @@
class TestModule(TransactionCase):
-
def setUp(self):
super().setUp()
- self.ProductProduct = self.env['product.product']
- self.ProductTemplate = self.env['product.template']
+ self.ProductProduct = self.env["product.product"]
+ self.ProductTemplate = self.env["product.template"]
# Custom Section
def _create_product(self, model, standard_price, sale_price, sale_tax_ids):
- if model == 'product':
+ if model == "product":
ModelObj = self.ProductProduct
else:
ModelObj = self.ProductTemplate
- return ModelObj.create({
- 'name': 'Demo Product',
- 'standard_price': standard_price,
- 'lst_price': sale_price,
- 'taxes_id': [(6, 0, sale_tax_ids)],
- })
+ return ModelObj.create(
+ {
+ "name": "Demo Product",
+ "standard_price": standard_price,
+ "lst_price": sale_price,
+ "taxes_id": [(6, 0, sale_tax_ids)],
+ }
+ )
# Test Section
def test_01_classic_margin(self):
- for model in ['product', 'template']:
+ for model in ["product", "template"]:
product = self._create_product(model, 50, 200, [])
+ self.assertEqual(product.standard_margin, 150, "Incorrect Standard Margin")
self.assertEqual(
- product.standard_margin, 150,
- "Incorrect Standard Margin")
- self.assertEqual(
- product.standard_margin_rate, 75.0,
- "Incorrect Standard Margin Rate")
+ product.standard_margin_rate, 75.0, "Incorrect Standard Margin Rate"
+ )
def test_02_margin_without_standard_price(self):
- for model in ['product', 'template']:
+ for model in ["product", "template"]:
product = self._create_product(model, 0, 200, [])
self.assertEqual(
- product.standard_margin, 200,
- "Incorrect Standard Margin (without standard price)")
+ product.standard_margin,
+ 200,
+ "Incorrect Standard Margin (without standard price)",
+ )
self.assertEqual(
- product.standard_margin_rate, 100.0,
- "Incorrect Standard Margin Rate (without standard price)")
+ product.standard_margin_rate,
+ 100.0,
+ "Incorrect Standard Margin Rate (without standard price)",
+ )
def test_03_margin_without_sale_price(self):
- for model in ['product', 'template']:
+ for model in ["product", "template"]:
product = self._create_product(model, 50, 0, [])
self.assertEqual(
- product.standard_margin, -50,
- "Incorrect Standard Margin (without sale price)")
+ product.standard_margin,
+ -50,
+ "Incorrect Standard Margin (without sale price)",
+ )
self.assertEqual(
- product.standard_margin_rate, 999.0,
- "Incorrect Standard Margin Rate (without sale price)")
+ product.standard_margin_rate,
+ 999.0,
+ "Incorrect Standard Margin Rate (without sale price)",
+ )
diff --git a/product_standard_margin/views/view_product_product.xml b/product_standard_margin/views/view_product_product.xml
index 2e1df3e90..6126c826c 100644
--- a/product_standard_margin/views/view_product_product.xml
+++ b/product_standard_margin/views/view_product_product.xml
@@ -1,4 +1,4 @@
-
+
@@ -6,11 +6,14 @@
-
+
-
-
-
+
+
+
@@ -20,11 +23,11 @@
-
+
-
-
+
+
diff --git a/product_standard_margin/views/view_product_template.xml b/product_standard_margin/views/view_product_template.xml
index da68bdd01..1dba3277f 100644
--- a/product_standard_margin/views/view_product_template.xml
+++ b/product_standard_margin/views/view_product_template.xml
@@ -1,15 +1,23 @@
-
+
product.template
-
-
-
+
+
+
From 53276b743475bf14ee9286292bc3695abc0999ba Mon Sep 17 00:00:00 2001
From: Cyril VINH-TUNG
Date: Wed, 15 Dec 2021 12:01:46 -1000
Subject: [PATCH 45/80] [MIG] product_standard_margin: Migration to 14.0
---
product_standard_margin/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/product_standard_margin/__manifest__.py b/product_standard_margin/__manifest__.py
index 02c211f6d..700801ddc 100644
--- a/product_standard_margin/__manifest__.py
+++ b/product_standard_margin/__manifest__.py
@@ -5,7 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Product Margin and Margin Rate",
- "version": "12.0.1.0.0",
+ "version": "14.0.1.0.0",
"author": "Camptocamp,GRAP,Odoo Community Association (OCA)",
"category": "Product",
"depends": ["account"],
From e0200f06f7a38c34434d1fcd9829781fbc56d91d Mon Sep 17 00:00:00 2001
From: Cyril VINH-TUNG
Date: Wed, 15 Dec 2021 12:44:37 -1000
Subject: [PATCH 46/80] [IMP] Add margin fields in product tree views
---
.../views/view_product_product.xml | 10 ++++++++++
.../views/view_product_template.xml | 19 +++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/product_standard_margin/views/view_product_product.xml b/product_standard_margin/views/view_product_product.xml
index 6126c826c..78cea78ae 100644
--- a/product_standard_margin/views/view_product_product.xml
+++ b/product_standard_margin/views/view_product_product.xml
@@ -32,4 +32,14 @@
+
+ product.product
+
+
+
+
+
+
+
+
diff --git a/product_standard_margin/views/view_product_template.xml b/product_standard_margin/views/view_product_template.xml
index 1dba3277f..eb3ac7423 100644
--- a/product_standard_margin/views/view_product_template.xml
+++ b/product_standard_margin/views/view_product_template.xml
@@ -21,4 +21,23 @@
+
+ product.template
+
+
+
+
+
+
+
+
From bd0b2ef753407e78c5d5b9c74bd18c648357bb1b Mon Sep 17 00:00:00 2001
From: Cyril VINH-TUNG
Date: Wed, 15 Dec 2021 18:23:55 -1000
Subject: [PATCH 47/80] [IMP] Add percentpie widget for rate field
---
product_standard_margin/readme/ROADMAP.rst | 5 -----
product_standard_margin/views/view_product_product.xml | 4 ++--
product_standard_margin/views/view_product_template.xml | 1 +
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/product_standard_margin/readme/ROADMAP.rst b/product_standard_margin/readme/ROADMAP.rst
index c711b0f1b..354994f4a 100644
--- a/product_standard_margin/readme/ROADMAP.rst
+++ b/product_standard_margin/readme/ROADMAP.rst
@@ -1,7 +1,2 @@
* This module will not work properly if used in a multicompany context with product
prices depending on the company.
-
-* It should be great to use the odoo widget ``percentpie`` for the display of the
- field ``standard_margin_rate`` but for the time being, the field is not displayed
- properly.
- Ref of the Odoo Issue: https://github.com/odoo/odoo/issues/42869
diff --git a/product_standard_margin/views/view_product_product.xml b/product_standard_margin/views/view_product_product.xml
index 78cea78ae..7521e805d 100644
--- a/product_standard_margin/views/view_product_product.xml
+++ b/product_standard_margin/views/view_product_product.xml
@@ -13,7 +13,7 @@
position="after"
>
-
+
@@ -27,7 +27,7 @@
-
+
diff --git a/product_standard_margin/views/view_product_template.xml b/product_standard_margin/views/view_product_template.xml
index eb3ac7423..c2adbfc45 100644
--- a/product_standard_margin/views/view_product_template.xml
+++ b/product_standard_margin/views/view_product_template.xml
@@ -16,6 +16,7 @@
/>
From 0c2c5bda105d0676ad2f3dbc5b61b0d3ec305927 Mon Sep 17 00:00:00 2001
From: Cyril VINH-TUNG
Date: Thu, 23 Dec 2021 09:52:15 -1000
Subject: [PATCH 48/80] [IMP] Add Markup Rate
---
product_standard_margin/i18n/fr.po | 63 ++++++++++++++-----
.../i18n/product_standard_margin.pot | 55 ++++++++++++++--
.../models/product_product.py | 18 ++++++
.../models/product_template.py | 17 +++++
.../readme/CONTRIBUTORS.rst | 1 +
.../readme/DESCRIPTION.rst | 9 ++-
.../views/view_product_product.xml | 3 +
.../views/view_product_template.xml | 10 +++
8 files changed, 153 insertions(+), 23 deletions(-)
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
index b168fe40c..b3d9c8301 100644
--- a/product_standard_margin/i18n/fr.po
+++ b/product_standard_margin/i18n/fr.po
@@ -4,41 +4,70 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-01-07 14:51+0000\n"
-"PO-Revision-Date: 2020-01-07 14:51+0000\n"
-"Last-Translator: <>\n"
+"POT-Creation-Date: 2021-12-23 19:48+0000\n"
+"PO-Revision-Date: 2021-12-23 19:48+0000\n"
+"Last-Translator: \n"
"Language-Team: \n"
-"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
+msgid "Display Name"
+msgstr "Nom affiché"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
+msgid "ID"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
+msgid "Last Modified on"
+msgstr "Dernière modification le"
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid ""
"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.. "
-"If no sale price set, will display 999.0"
+"form (not based on historical values).Take care of tax include and exclude.."
+" If no sale price set, will display 999.0"
msgstr ""
"Taux de marque théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
"taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le "
"taux sera de 999.0"
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_markup_rate
+msgid ""
+"Markup rate is [ Theorical Margin / cost price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.."
+" If no cost price set, will display 999.0"
+msgstr ""
+"Taux de marge théorique [ (PV unitaire - Coût unitaire ) / Coût unitaire du "
+"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
+"taux tient compte des PV TTC (TVA incluse). Si aucun coût n'a été saisi, le "
+"taux sera de 999.0"
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
-#, fuzzy
msgid ""
"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.. "
-"If no sale price set, will display 999.0"
+"form (not based on historical values).Take care of tax include and exclude.."
+" If no sale price set, will display 999.0"
msgstr ""
-"Taux de marque théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
+"Taux de marge théorique [ (PV unitaire - Coût unitaire ) / Coût unitaire du "
"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
-"taux tient compte des PV TTC (TVA incluse). Si aucun PV n'a été saisi, le "
+"taux tient compte des PV TTC (TVA incluse). Si aucun coût n'a été saisi, le "
"taux sera de 999.0"
#. module: product_standard_margin
@@ -73,10 +102,16 @@ msgstr "Taux de marque Théorique (%)"
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
msgid ""
-"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
-"(not based on historical values). Take care of tax include and exclude. If "
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form"
+" (not based on historical values). Take care of tax include and exclude. If "
"no sale price, the margin will be negativ."
msgstr ""
"Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient "
"pas compte de la facturation effective). Ce taux tient compte des PV TTC "
"(TVA incluse). Si aucun PV n'a été saisi, la marge sera négative."
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_markup_rate
+msgid "Theorical Markup (%)"
+msgstr "Taux de marge Théorique (%)"
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
index fdd3b6056..b9358712d 100644
--- a/product_standard_margin/i18n/product_standard_margin.pot
+++ b/product_standard_margin/i18n/product_standard_margin.pot
@@ -1,26 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * product_standard_margin
+# * product_standard_margin
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: <>\n"
+"POT-Creation-Date: 2021-12-23 19:48+0000\n"
+"PO-Revision-Date: 2021-12-23 19:48+0000\n"
+"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
+msgid "ID"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
+msgid "Last Modified on"
+msgstr ""
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
-msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgid ""
+"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.."
+" If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_markup_rate
+msgid ""
+"Markup rate is [ Theorical Margin / cost price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.."
+" If no cost price set, will display 999.0"
msgstr ""
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
-msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.."
+" If no sale price set, will display 999.0"
msgstr ""
#. module: product_standard_margin
@@ -54,6 +89,14 @@ msgstr ""
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
-msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form"
+" (not based on historical values). Take care of tax include and exclude. If "
+"no sale price, the margin will be negativ."
msgstr ""
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_markup_rate
+msgid "Theorical Markup (%)"
+msgstr ""
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 5f3d52af7..4da7da4f9 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -41,6 +41,16 @@ class ProductProduct(models.Model):
"Take care of tax include and exclude.. If no sale price "
"set, will display 999.0",
)
+ standard_markup_rate = fields.Float(
+ compute="_compute_margin",
+ string="Theorical Markup (%)",
+ store=True,
+ digits=dp.get_precision("Product Price"),
+ help="Markup rate is [ Theorical Margin / cost price (Wo Tax) ] "
+ "of the product form (not based on historical values)."
+ "Take care of tax include and exclude.. If no cost price "
+ "set, will display 999.0",
+ )
# Compute Section
@api.depends(
@@ -67,3 +77,11 @@ def _compute_margin(self):
/ product.list_price_vat_excl
* 100
)
+ if product.standard_price == 0:
+ product.standard_markup_rate = 999.0
+ else:
+ product.standard_markup_rate = (
+ (product.list_price_vat_excl - product.standard_price)
+ / product.standard_price
+ * 100
+ )
diff --git a/product_standard_margin/models/product_template.py b/product_standard_margin/models/product_template.py
index 8458feb98..d45ff4036 100644
--- a/product_standard_margin/models/product_template.py
+++ b/product_standard_margin/models/product_template.py
@@ -38,6 +38,15 @@ class ProductTemplate(models.Model):
"Take care of tax include and exclude.. If no sale price "
"set, will display 999.0",
)
+ standard_markup_rate = fields.Float(
+ compute="_compute_margin",
+ string="Theorical Markup (%)",
+ digits=dp.get_precision("Product Price"),
+ help="Markup rate is [ Theorical Margin / cost price (Wo Tax) ] "
+ "of the product form (not based on historical values)."
+ "Take care of tax include and exclude.. If no cost price "
+ "set, will display 999.0",
+ )
# Compute Section
@api.depends(
@@ -66,3 +75,11 @@ def _compute_margin(self):
/ template.list_price_vat_excl
* 100
)
+ if template.standard_price == 0:
+ template.standard_markup_rate = 999.0
+ else:
+ template.standard_markup_rate = (
+ (template.list_price_vat_excl - template.standard_price)
+ / template.standard_price
+ * 100
+ )
diff --git a/product_standard_margin/readme/CONTRIBUTORS.rst b/product_standard_margin/readme/CONTRIBUTORS.rst
index 1e1d54b12..76e09f2ee 100644
--- a/product_standard_margin/readme/CONTRIBUTORS.rst
+++ b/product_standard_margin/readme/CONTRIBUTORS.rst
@@ -2,3 +2,4 @@
* Yannick Vaucher
* Joël Grand-Guillaume
* Sylvain Le Gal (https://twitter.com/legalsylvain)
+* Cyril Vinh-Tung
diff --git a/product_standard_margin/readme/DESCRIPTION.rst b/product_standard_margin/readme/DESCRIPTION.rst
index 3698a5682..f1db3a839 100644
--- a/product_standard_margin/readme/DESCRIPTION.rst
+++ b/product_standard_margin/readme/DESCRIPTION.rst
@@ -1,9 +1,12 @@
-Add a field on the product form that compute the standard (or theorical)
-margin based on the current values of sale and standard price present in
-the product form. We take care of taxe included or excluded.
+Add 2 fields on the product form that compute the standard (or theorical)
+margin and markup based on the current values of sale and standard price
+present in the product form. We take care of taxe included or excluded.
It will just compute it as follow:
+Margin :
(Sale Price without tax - Standard Price) / Sale Price without tax
+Markup :
+(Sale Price without tax - Standard Price) / Standard Price
.. figure:: ../static/description/product_form.png
diff --git a/product_standard_margin/views/view_product_product.xml b/product_standard_margin/views/view_product_product.xml
index 7521e805d..8c7d865c7 100644
--- a/product_standard_margin/views/view_product_product.xml
+++ b/product_standard_margin/views/view_product_product.xml
@@ -14,6 +14,7 @@
>
+
@@ -28,6 +29,7 @@
+
@@ -39,6 +41,7 @@
+
diff --git a/product_standard_margin/views/view_product_template.xml b/product_standard_margin/views/view_product_template.xml
index c2adbfc45..715e5c417 100644
--- a/product_standard_margin/views/view_product_template.xml
+++ b/product_standard_margin/views/view_product_template.xml
@@ -19,6 +19,11 @@
widget="percentpie"
attrs="{'invisible': [('product_variant_count', '>', 1)]}"
/>
+
@@ -38,6 +43,11 @@
attrs="{'invisible': [('product_variant_count', '>', 1)]}"
optional="hide"
/>
+
From 995e0244b50db504f45b8301b3f2aa45776003e2 Mon Sep 17 00:00:00 2001
From: oca-ci
Date: Thu, 16 Feb 2023 13:22:12 +0000
Subject: [PATCH 49/80] [UPD] Update product_standard_margin.pot
---
product_standard_margin/i18n/product_standard_margin.pot | 2 --
1 file changed, 2 deletions(-)
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
index b9358712d..0278558bd 100644
--- a/product_standard_margin/i18n/product_standard_margin.pot
+++ b/product_standard_margin/i18n/product_standard_margin.pot
@@ -6,8 +6,6 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-12-23 19:48+0000\n"
-"PO-Revision-Date: 2021-12-23 19:48+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
From b3345e442d762c16aa64593096b4e31b69bf6b2f Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Thu, 16 Feb 2023 13:25:27 +0000
Subject: [PATCH 50/80] [UPD] README.rst
---
product_standard_margin/README.rst | 27 +++++++++----------
.../static/description/index.html | 24 ++++++++---------
2 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/product_standard_margin/README.rst b/product_standard_margin/README.rst
index 67f6efbd7..eca4cbeea 100644
--- a/product_standard_margin/README.rst
+++ b/product_standard_margin/README.rst
@@ -14,25 +14,28 @@ Product Margin and Margin Rate
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmargin--analysis-lightgray.png?logo=github
- :target: https://github.com/OCA/margin-analysis/tree/12.0/product_standard_margin
+ :target: https://github.com/OCA/margin-analysis/tree/14.0/product_standard_margin
:alt: OCA/margin-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/margin-analysis-12-0/margin-analysis-12-0-product_standard_margin
+ :target: https://translation.odoo-community.org/projects/margin-analysis-14-0/margin-analysis-14-0-product_standard_margin
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/132/12.0
+ :target: https://runbot.odoo-community.org/runbot/132/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
-Add a field on the product form that compute the standard (or theorical)
-margin based on the current values of sale and standard price present in
-the product form. We take care of taxe included or excluded.
+Add 2 fields on the product form that compute the standard (or theorical)
+margin and markup based on the current values of sale and standard price
+present in the product form. We take care of taxe included or excluded.
It will just compute it as follow:
+Margin :
(Sale Price without tax - Standard Price) / Sale Price without tax
+Markup :
+(Sale Price without tax - Standard Price) / Standard Price
-.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/12.0/product_standard_margin/static/description/product_form.png
+.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/14.0/product_standard_margin/static/description/product_form.png
**Note:**
@@ -54,18 +57,13 @@ Known issues / Roadmap
* This module will not work properly if used in a multicompany context with product
prices depending on the company.
-* It should be great to use the odoo widget ``percentpie`` for the display of the
- field ``standard_margin_rate`` but for the time being, the field is not displayed
- properly.
- Ref of the Odoo Issue: https://github.com/odoo/odoo/issues/42869
-
Bug Tracker
===========
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -85,6 +83,7 @@ Contributors
* Yannick Vaucher
* Joël Grand-Guillaume
* Sylvain Le Gal (https://twitter.com/legalsylvain)
+* Cyril Vinh-Tung
Maintainers
~~~~~~~~~~~
@@ -107,6 +106,6 @@ Current `maintainer `__:
|maintainer-legalsylvain|
-This module is part of the `OCA/margin-analysis `_ project on GitHub.
+This module is part of the `OCA/margin-analysis `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/product_standard_margin/static/description/index.html b/product_standard_margin/static/description/index.html
index 184d8d251..af76cded3 100644
--- a/product_standard_margin/static/description/index.html
+++ b/product_standard_margin/static/description/index.html
@@ -367,14 +367,17 @@ Product Margin and Margin Rate
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

-Add a field on the product form that compute the standard (or theorical)
-margin based on the current values of sale and standard price present in
-the product form. We take care of taxe included or excluded.
+

+Add 2 fields on the product form that compute the standard (or theorical)
+margin and markup based on the current values of sale and standard price
+present in the product form. We take care of taxe included or excluded.
It will just compute it as follow:
-(Sale Price without tax - Standard Price) / Sale Price without tax
+Margin :
+(Sale Price without tax - Standard Price) / Sale Price without tax
+Markup :
+(Sale Price without tax - Standard Price) / Standard Price
Note:
As this module will base his simple computation on sale and cost prices,
@@ -401,10 +404,6 @@
- This module will not work properly if used in a multicompany context with product
prices depending on the company.
-- It should be great to use the odoo widget percentpie for the display of the
-field standard_margin_rate but for the time being, the field is not displayed
-properly.
-Ref of the Odoo Issue: https://github.com/odoo/odoo/issues/42869
@@ -412,7 +411,7 @@
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
+
feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -442,7 +442,7 @@
promote its widespread use.
Current maintainer:

-
This module is part of the OCA/margin-analysis project on GitHub.
+
This module is part of the OCA/margin-analysis project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
From 5a24f791f85fa0240a7c2a2a419df8925455d904 Mon Sep 17 00:00:00 2001
From: Weblate
Date: Thu, 16 Feb 2023 16:44:57 +0000
Subject: [PATCH 51/80] Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.
Translation: margin-analysis-14.0/margin-analysis-14.0-product_standard_margin
Translate-URL: https://translation.odoo-community.org/projects/margin-analysis-14-0/margin-analysis-14-0-product_standard_margin/
---
product_standard_margin/i18n/de.po | 58 +++++++++++++++++++++++----
product_standard_margin/i18n/fr.po | 17 ++++----
product_standard_margin/i18n/nl.po | 33 +++++++++++++++
product_standard_margin/i18n/pt.po | 50 +++++++++++++++++++++--
product_standard_margin/i18n/pt_BR.po | 50 +++++++++++++++++++++--
5 files changed, 184 insertions(+), 24 deletions(-)
diff --git a/product_standard_margin/i18n/de.po b/product_standard_margin/i18n/de.po
index 1386c8ad9..dd31fc926 100644
--- a/product_standard_margin/i18n/de.po
+++ b/product_standard_margin/i18n/de.po
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * product_standard_margin
+# * product_standard_margin
#
msgid ""
msgstr ""
@@ -16,18 +16,51 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.10\n"
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
+msgid "ID"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
+msgid "Last Modified on"
+msgstr ""
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
-msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgid ""
+"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
msgstr ""
"Der Margensatz ist [ Theoretische Marge / Verkaufspreis (Ohne Steuern) ] des "
"Produkts (nicht auf historischen Werten basierend), wobei darauf zu achten "
"ist, Steuern ein- und auszuschließen. Wenn kein Verkaufspreis festgelegt "
"wurde, wird 999.0 angezeigt"
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_markup_rate
+msgid ""
+"Markup rate is [ Theorical Margin / cost price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no cost price set, will display 999.0"
+msgstr ""
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
-msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
msgstr ""
"Der Aufschlagssatz ist [ Theoretische Marge / Verkaufspreis (Ohne Steuern) ] "
"des Produkts (nicht auf historischen Werten basierend), mit und ohne Steuer. "
@@ -64,9 +97,18 @@ msgstr "Theoretische Marge (%)"
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
-msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values). Take care of tax include and exclude. If "
+"no sale price, the margin will be negativ."
+msgstr ""
+"Theoretische Gewinnmarge ist [ Verkaufspreis (Ohne Steuern) - "
+"Einkaufspreis ] des Produkts (nicht auf historischen Werten basierend). "
+"Achten Sie darauf, Steuern ein- und auszuschließen. Wenn kein Verkaufspreis "
+"angegeben wird, ist die Marge negativ."
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_markup_rate
+msgid "Theorical Markup (%)"
msgstr ""
-"Theoretische Gewinnmarge ist [ Verkaufspreis (Ohne Steuern) - Einkaufspreis ]"
-" des Produkts (nicht auf historischen Werten basierend). Achten Sie darauf, "
-"Steuern ein- und auszuschließen. Wenn kein Verkaufspreis angegeben wird, ist "
-"die Marge negativ."
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
index b3d9c8301..730ded356 100644
--- a/product_standard_margin/i18n/fr.po
+++ b/product_standard_margin/i18n/fr.po
@@ -10,6 +10,7 @@ msgstr ""
"PO-Revision-Date: 2021-12-23 19:48+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
@@ -37,8 +38,8 @@ msgstr "Dernière modification le"
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid ""
"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.."
-" If no sale price set, will display 999.0"
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
msgstr ""
"Taux de marque théorique [ (PV unitaire - Coût unitaire ) / PV unitaire du "
"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
@@ -50,8 +51,8 @@ msgstr ""
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_markup_rate
msgid ""
"Markup rate is [ Theorical Margin / cost price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.."
-" If no cost price set, will display 999.0"
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no cost price set, will display 999.0"
msgstr ""
"Taux de marge théorique [ (PV unitaire - Coût unitaire ) / Coût unitaire du "
"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
@@ -62,8 +63,8 @@ msgstr ""
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
msgid ""
"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.."
-" If no sale price set, will display 999.0"
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
msgstr ""
"Taux de marge théorique [ (PV unitaire - Coût unitaire ) / Coût unitaire du "
"formulaire Produit] (ne tient pas compte de la facturation effective). Ce "
@@ -102,8 +103,8 @@ msgstr "Taux de marque Théorique (%)"
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
msgid ""
-"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form"
-" (not based on historical values). Take care of tax include and exclude. If "
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values). Take care of tax include and exclude. If "
"no sale price, the margin will be negativ."
msgstr ""
"Marge théorique [ Vente unitaire HT - coût unitaire ] du produit (ne tient "
diff --git a/product_standard_margin/i18n/nl.po b/product_standard_margin/i18n/nl.po
index 0cc539b5b..a964ef6bf 100644
--- a/product_standard_margin/i18n/nl.po
+++ b/product_standard_margin/i18n/nl.po
@@ -18,6 +18,24 @@ msgstr ""
"Plural-Forms: \n"
"X-Generator: Poedit 1.5.4\n"
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
+msgid "ID"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
+msgid "Last Modified on"
+msgstr ""
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
#, fuzzy
@@ -31,6 +49,15 @@ msgstr ""
"rekening met prijzen incl. en excl. BTW. Indien geen verkooprijs is "
"ingevoerd, wordt 999,0 weergegeven."
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_markup_rate
+msgid ""
+"Markup rate is [ Theorical Margin / cost price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no cost price set, will display 999.0"
+msgstr ""
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
msgid ""
@@ -86,6 +113,12 @@ msgstr ""
"prijzen incl. en excl. BTW. Indien geen verkooprijs is ingevoerd, zal de "
"marge negatief zijn."
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_markup_rate
+msgid "Theorical Markup (%)"
+msgstr ""
+
#~ msgid "Error: Invalid ean code"
#~ msgstr "Fout: ongeldige ean code"
diff --git a/product_standard_margin/i18n/pt.po b/product_standard_margin/i18n/pt.po
index 5be85e4ea..4495883b4 100644
--- a/product_standard_margin/i18n/pt.po
+++ b/product_standard_margin/i18n/pt.po
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * product_standard_margin
+# * product_standard_margin
#
msgid ""
msgstr ""
@@ -14,14 +14,47 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
+msgid "ID"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
+msgid "Last Modified on"
+msgstr ""
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
-msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgid ""
+"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_markup_rate
+msgid ""
+"Markup rate is [ Theorical Margin / cost price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no cost price set, will display 999.0"
msgstr ""
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
-msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
msgstr ""
#. module: product_standard_margin
@@ -55,5 +88,14 @@ msgstr ""
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
-msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values). Take care of tax include and exclude. If "
+"no sale price, the margin will be negativ."
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_markup_rate
+msgid "Theorical Markup (%)"
msgstr ""
diff --git a/product_standard_margin/i18n/pt_BR.po b/product_standard_margin/i18n/pt_BR.po
index c8a043599..d3c442b05 100644
--- a/product_standard_margin/i18n/pt_BR.po
+++ b/product_standard_margin/i18n/pt_BR.po
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * product_standard_margin
+# * product_standard_margin
#
msgid ""
msgstr ""
@@ -14,14 +14,47 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
+msgid "ID"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
+msgid "Last Modified on"
+msgstr ""
+
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
-msgid "Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgid ""
+"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_markup_rate
+msgid ""
+"Markup rate is [ Theorical Margin / cost price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no cost price set, will display 999.0"
msgstr ""
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
-msgid "Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).Take care of tax include and exclude.. If no sale price set, will display 999.0"
+msgid ""
+"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and exclude.. "
+"If no sale price set, will display 999.0"
msgstr ""
#. module: product_standard_margin
@@ -55,5 +88,14 @@ msgstr ""
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
-msgid "Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values). Take care of tax include and exclude. If no sale price, the margin will be negativ."
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form "
+"(not based on historical values). Take care of tax include and exclude. If "
+"no sale price, the margin will be negativ."
+msgstr ""
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_markup_rate
+msgid "Theorical Markup (%)"
msgstr ""
From b8d94142831c1febb1b151c1177230ac1a9040dd Mon Sep 17 00:00:00 2001
From: Denis Leemann
Date: Fri, 17 Feb 2023 13:36:08 +0100
Subject: [PATCH 52/80] [MIG] product_standard_margin: Migration to 15.0
---
product_standard_margin/__manifest__.py | 2 +-
product_standard_margin/models/product_product.py | 4 ++--
product_standard_margin/models/product_template.py | 2 +-
product_standard_margin/tests/test_module.py | 11 ++++++-----
.../views/view_product_product.xml | 2 +-
5 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/product_standard_margin/__manifest__.py b/product_standard_margin/__manifest__.py
index 700801ddc..b19305242 100644
--- a/product_standard_margin/__manifest__.py
+++ b/product_standard_margin/__manifest__.py
@@ -5,7 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Product Margin and Margin Rate",
- "version": "14.0.1.0.0",
+ "version": "15.0.1.0.0",
"author": "Camptocamp,GRAP,Odoo Community Association (OCA)",
"category": "Product",
"depends": ["account"],
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 4da7da4f9..43d77b151 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -54,7 +54,7 @@ class ProductProduct(models.Model):
# Compute Section
@api.depends(
- "lst_price",
+ "list_price",
"product_tmpl_id.list_price",
"standard_price",
"taxes_id.price_include",
@@ -64,7 +64,7 @@ class ProductProduct(models.Model):
def _compute_margin(self):
for product in self:
product.list_price_vat_excl = product.taxes_id.compute_all(
- product.lst_price, product=product
+ product.list_price, product=product
)["total_excluded"]
product.standard_margin = (
product.list_price_vat_excl - product.standard_price
diff --git a/product_standard_margin/models/product_template.py b/product_standard_margin/models/product_template.py
index d45ff4036..f0382201d 100644
--- a/product_standard_margin/models/product_template.py
+++ b/product_standard_margin/models/product_template.py
@@ -50,7 +50,7 @@ class ProductTemplate(models.Model):
# Compute Section
@api.depends(
- "lst_price",
+ "list_price",
"standard_price",
"taxes_id.price_include",
"taxes_id.amount",
diff --git a/product_standard_margin/tests/test_module.py b/product_standard_margin/tests/test_module.py
index f628568bd..ead2bed82 100644
--- a/product_standard_margin/tests/test_module.py
+++ b/product_standard_margin/tests/test_module.py
@@ -6,10 +6,11 @@
class TestModule(TransactionCase):
- def setUp(self):
- super().setUp()
- self.ProductProduct = self.env["product.product"]
- self.ProductTemplate = self.env["product.template"]
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ cls.ProductProduct = cls.env["product.product"]
+ cls.ProductTemplate = cls.env["product.template"]
# Custom Section
def _create_product(self, model, standard_price, sale_price, sale_tax_ids):
@@ -21,7 +22,7 @@ def _create_product(self, model, standard_price, sale_price, sale_tax_ids):
{
"name": "Demo Product",
"standard_price": standard_price,
- "lst_price": sale_price,
+ "list_price": sale_price,
"taxes_id": [(6, 0, sale_tax_ids)],
}
)
diff --git a/product_standard_margin/views/view_product_product.xml b/product_standard_margin/views/view_product_product.xml
index 8c7d865c7..1dd6b8991 100644
--- a/product_standard_margin/views/view_product_product.xml
+++ b/product_standard_margin/views/view_product_product.xml
@@ -5,7 +5,7 @@
product.product
-
+
Date: Mon, 20 Feb 2023 12:16:45 +0000
Subject: [PATCH 53/80] [UPD] Update product_standard_margin.pot
---
.../i18n/product_standard_margin.pot | 20 +------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
index 0278558bd..8c0b59d3a 100644
--- a/product_standard_margin/i18n/product_standard_margin.pot
+++ b/product_standard_margin/i18n/product_standard_margin.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 14.0\n"
+"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -13,24 +13,6 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
-msgid "Display Name"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
-msgid "ID"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
-msgid "Last Modified on"
-msgstr ""
-
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid ""
From 342b5c0e35d9bce68f981e4b38d2e8192538d59b Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Mon, 20 Feb 2023 12:19:16 +0000
Subject: [PATCH 54/80] [UPD] README.rst
---
product_standard_margin/README.rst | 12 ++++++------
.../static/description/index.html | 8 ++++----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/product_standard_margin/README.rst b/product_standard_margin/README.rst
index eca4cbeea..318b2bf6d 100644
--- a/product_standard_margin/README.rst
+++ b/product_standard_margin/README.rst
@@ -14,13 +14,13 @@ Product Margin and Margin Rate
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmargin--analysis-lightgray.png?logo=github
- :target: https://github.com/OCA/margin-analysis/tree/14.0/product_standard_margin
+ :target: https://github.com/OCA/margin-analysis/tree/15.0/product_standard_margin
:alt: OCA/margin-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/margin-analysis-14-0/margin-analysis-14-0-product_standard_margin
+ :target: https://translation.odoo-community.org/projects/margin-analysis-15-0/margin-analysis-15-0-product_standard_margin
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/132/14.0
+ :target: https://runbot.odoo-community.org/runbot/132/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -35,7 +35,7 @@ Margin :
Markup :
(Sale Price without tax - Standard Price) / Standard Price
-.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/14.0/product_standard_margin/static/description/product_form.png
+.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/15.0/product_standard_margin/static/description/product_form.png
**Note:**
@@ -63,7 +63,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -106,6 +106,6 @@ Current `maintainer `__:
|maintainer-legalsylvain|
-This module is part of the `OCA/margin-analysis `_ project on GitHub.
+This module is part of the `OCA/margin-analysis `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/product_standard_margin/static/description/index.html b/product_standard_margin/static/description/index.html
index af76cded3..18c509a6d 100644
--- a/product_standard_margin/static/description/index.html
+++ b/product_standard_margin/static/description/index.html
@@ -367,7 +367,7 @@ Product Margin and Margin Rate
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

Add 2 fields on the product form that compute the standard (or theorical)
margin and markup based on the current values of sale and standard price
present in the product form. We take care of taxe included or excluded.
@@ -377,7 +377,7 @@ Product Margin and Margin Rate
Markup :
(Sale Price without tax - Standard Price) / Standard Price
Note:
As this module will base his simple computation on sale and cost prices,
@@ -411,7 +411,7 @@
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
From c72cf21e86a4f14eeb5e6f20a15c1284501a9268 Mon Sep 17 00:00:00 2001
From: Weblate
Date: Mon, 20 Feb 2023 16:07:59 +0000
Subject: [PATCH 55/80] Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.
Translation: margin-analysis-15.0/margin-analysis-15.0-product_standard_margin
Translate-URL: https://translation.odoo-community.org/projects/margin-analysis-15-0/margin-analysis-15-0-product_standard_margin/
---
product_standard_margin/i18n/de.po | 18 ------------------
product_standard_margin/i18n/fr.po | 24 ++++++------------------
product_standard_margin/i18n/nl.po | 18 ------------------
product_standard_margin/i18n/pt.po | 18 ------------------
product_standard_margin/i18n/pt_BR.po | 18 ------------------
5 files changed, 6 insertions(+), 90 deletions(-)
diff --git a/product_standard_margin/i18n/de.po b/product_standard_margin/i18n/de.po
index dd31fc926..f2fb147fa 100644
--- a/product_standard_margin/i18n/de.po
+++ b/product_standard_margin/i18n/de.po
@@ -16,24 +16,6 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.10\n"
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
-msgid "Display Name"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
-msgid "ID"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
-msgid "Last Modified on"
-msgstr ""
-
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid ""
diff --git a/product_standard_margin/i18n/fr.po b/product_standard_margin/i18n/fr.po
index 730ded356..9072079c9 100644
--- a/product_standard_margin/i18n/fr.po
+++ b/product_standard_margin/i18n/fr.po
@@ -16,24 +16,6 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
-msgid "Display Name"
-msgstr "Nom affiché"
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
-msgid "ID"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
-msgid "Last Modified on"
-msgstr "Dernière modification le"
-
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid ""
@@ -116,3 +98,9 @@ msgstr ""
#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_markup_rate
msgid "Theorical Markup (%)"
msgstr "Taux de marge Théorique (%)"
+
+#~ msgid "Display Name"
+#~ msgstr "Nom affiché"
+
+#~ msgid "Last Modified on"
+#~ msgstr "Dernière modification le"
diff --git a/product_standard_margin/i18n/nl.po b/product_standard_margin/i18n/nl.po
index a964ef6bf..44f1000a2 100644
--- a/product_standard_margin/i18n/nl.po
+++ b/product_standard_margin/i18n/nl.po
@@ -18,24 +18,6 @@ msgstr ""
"Plural-Forms: \n"
"X-Generator: Poedit 1.5.4\n"
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
-msgid "Display Name"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
-msgid "ID"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
-msgid "Last Modified on"
-msgstr ""
-
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
#, fuzzy
diff --git a/product_standard_margin/i18n/pt.po b/product_standard_margin/i18n/pt.po
index 4495883b4..12a51a785 100644
--- a/product_standard_margin/i18n/pt.po
+++ b/product_standard_margin/i18n/pt.po
@@ -14,24 +14,6 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
-msgid "Display Name"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
-msgid "ID"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
-msgid "Last Modified on"
-msgstr ""
-
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid ""
diff --git a/product_standard_margin/i18n/pt_BR.po b/product_standard_margin/i18n/pt_BR.po
index d3c442b05..a6f8876e6 100644
--- a/product_standard_margin/i18n/pt_BR.po
+++ b/product_standard_margin/i18n/pt_BR.po
@@ -14,24 +14,6 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__display_name
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__display_name
-msgid "Display Name"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__id
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__id
-msgid "ID"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_product____last_update
-#: model:ir.model.fields,field_description:product_standard_margin.field_product_template____last_update
-msgid "Last Modified on"
-msgstr ""
-
#. module: product_standard_margin
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid ""
From d1b6b302ace97f212037890815ad1e742fbe5dad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro?=
Date: Mon, 5 Jun 2023 11:32:09 +0200
Subject: [PATCH 56/80] [MIG] product_standard_margin: Migration to 16.0
---
product_standard_margin/__manifest__.py | 2 +-
product_standard_margin/i18n/es.po | 91 +++++++++++++++++++
.../models/product_product.py | 12 +--
.../models/product_template.py | 10 +-
4 files changed, 101 insertions(+), 14 deletions(-)
create mode 100644 product_standard_margin/i18n/es.po
diff --git a/product_standard_margin/__manifest__.py b/product_standard_margin/__manifest__.py
index b19305242..0c63670f7 100644
--- a/product_standard_margin/__manifest__.py
+++ b/product_standard_margin/__manifest__.py
@@ -5,7 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Product Margin and Margin Rate",
- "version": "15.0.1.0.0",
+ "version": "16.0.1.0.0",
"author": "Camptocamp,GRAP,Odoo Community Association (OCA)",
"category": "Product",
"depends": ["account"],
diff --git a/product_standard_margin/i18n/es.po b/product_standard_margin/i18n/es.po
new file mode 100644
index 000000000..0e1b1ebc6
--- /dev/null
+++ b/product_standard_margin/i18n/es.po
@@ -0,0 +1,91 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * product_standard_margin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 16.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2023-06-05 09:26+0000\n"
+"PO-Revision-Date: 2023-06-05 11:27+0200\n"
+"Last-Translator: \n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+"Language: es\n"
+"X-Generator: Poedit 2.0.6\n"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
+msgid ""
+"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and "
+"exclude.. If no sale price set, will display 999.0"
+msgstr ""
+"La tasa de margen es [ Margen teórico / precio de venta (sin impuestos) ] "
+"de la ficha del producto (no basado en valores históricos). Tenga cuidado "
+"de impuestos incluidos y excluidos. Si no hay precio de venta establecido "
+"mostrará 999.0"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_markup_rate
+msgid ""
+"Markup rate is [ Theorical Margin / cost price (Wo Tax) ] of the product "
+"form (not based on historical values).Take care of tax include and "
+"exclude.. If no cost price set, will display 999.0"
+msgstr ""
+"La tasa de Markup es [ Margen teórico / precio de coste (sin impuestos) ] "
+"de la ficha del producto (no basado en valores históricos). Tenga cuidado "
+"de impuestos incluidos y excluidos. Si no hay precio de coste establecido "
+"mostrará 999.0"
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_template
+msgid "Product"
+msgstr "Producto"
+
+#. module: product_standard_margin
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product Variant"
+msgstr "Variante de producto"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__list_price_vat_excl
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__list_price_vat_excl
+msgid "Sale Price VAT Excluded"
+msgstr "Precio de venta sin impuestos"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin
+msgid "Theorical Margin"
+msgstr "Margen teórico"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_margin_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_margin_rate
+msgid "Theorical Margin (%)"
+msgstr "Margen teórico (%)"
+
+#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin
+msgid ""
+"Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product "
+"form (not based on historical values). Take care of tax include and "
+"exclude. If no sale price, the margin will be negativ."
+msgstr ""
+"El margen teórico es [ precio de venta (sin impuestos) - precio de coste ] "
+"de la ficha del producto (no basado en valores históricos). Tenga cuidado "
+"de impuestos incluidos y excluidos. Si no hay precio de venta el margen "
+"será negativo."
+
+#. module: product_standard_margin
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_product__standard_markup_rate
+#: model:ir.model.fields,field_description:product_standard_margin.field_product_template__standard_markup_rate
+msgid "Theorical Markup (%)"
+msgstr "Markup teórico (%)"
diff --git a/product_standard_margin/models/product_product.py b/product_standard_margin/models/product_product.py
index 43d77b151..1ad77b301 100644
--- a/product_standard_margin/models/product_product.py
+++ b/product_standard_margin/models/product_product.py
@@ -6,8 +6,6 @@
from odoo import api, fields, models
-import odoo.addons.decimal_precision as dp
-
class ProductProduct(models.Model):
_inherit = "product.product"
@@ -17,14 +15,14 @@ class ProductProduct(models.Model):
compute="_compute_margin",
string="Sale Price VAT Excluded",
store=True,
- digits=dp.get_precision("Product Price"),
+ digits="Product Price",
)
standard_margin = fields.Float(
compute="_compute_margin",
string="Theorical Margin",
store=True,
- digits=dp.get_precision("Product Price"),
+ digits="Product Price",
help="Theorical Margin is [ sale price (Wo Tax) - cost price ] "
"of the product form (not based on historical values). "
"Take care of tax include and exclude. If no sale price, "
@@ -35,8 +33,8 @@ class ProductProduct(models.Model):
compute="_compute_margin",
string="Theorical Margin (%)",
store=True,
- digits=dp.get_precision("Product Price"),
- help="Markup rate is [ Theorical Margin / sale price (Wo Tax) ] "
+ digits="Product Price",
+ help="Margin rate is [ Theorical Margin / sale price (Wo Tax) ] "
"of the product form (not based on historical values)."
"Take care of tax include and exclude.. If no sale price "
"set, will display 999.0",
@@ -45,7 +43,7 @@ class ProductProduct(models.Model):
compute="_compute_margin",
string="Theorical Markup (%)",
store=True,
- digits=dp.get_precision("Product Price"),
+ digits="Product Price",
help="Markup rate is [ Theorical Margin / cost price (Wo Tax) ] "
"of the product form (not based on historical values)."
"Take care of tax include and exclude.. If no cost price "
diff --git a/product_standard_margin/models/product_template.py b/product_standard_margin/models/product_template.py
index f0382201d..658b1ce34 100644
--- a/product_standard_margin/models/product_template.py
+++ b/product_standard_margin/models/product_template.py
@@ -6,8 +6,6 @@
from odoo import api, fields, models
-import odoo.addons.decimal_precision as dp
-
class ProductTemplate(models.Model):
_inherit = "product.template"
@@ -16,13 +14,13 @@ class ProductTemplate(models.Model):
list_price_vat_excl = fields.Float(
compute="_compute_margin",
string="Sale Price VAT Excluded",
- digits=dp.get_precision("Product Price"),
+ digits="Product Price",
)
standard_margin = fields.Float(
compute="_compute_margin",
string="Theorical Margin",
- digits=dp.get_precision("Product Price"),
+ digits="Product Price",
help="Theorical Margin is [ sale price (Wo Tax) - cost price ] "
"of the product form (not based on historical values). "
"Take care of tax include and exclude. If no sale price, "
@@ -32,7 +30,7 @@ class ProductTemplate(models.Model):
standard_margin_rate = fields.Float(
compute="_compute_margin",
string="Theorical Margin (%)",
- digits=dp.get_precision("Product Price"),
+ digits="Product Price",
help="Margin rate is [ Theorical Margin / sale price (Wo Tax) ] "
"of the product form (not based on historical values)."
"Take care of tax include and exclude.. If no sale price "
@@ -41,7 +39,7 @@ class ProductTemplate(models.Model):
standard_markup_rate = fields.Float(
compute="_compute_margin",
string="Theorical Markup (%)",
- digits=dp.get_precision("Product Price"),
+ digits="Product Price",
help="Markup rate is [ Theorical Margin / cost price (Wo Tax) ] "
"of the product form (not based on historical values)."
"Take care of tax include and exclude.. If no cost price "
From 2ee7d9da1732c1d2bfa9f22e55bb9b00c07db753 Mon Sep 17 00:00:00 2001
From: oca-ci
Date: Wed, 21 Jun 2023 15:15:23 +0000
Subject: [PATCH 57/80] [UPD] Update product_standard_margin.pot
---
.../i18n/product_standard_margin.pot | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/product_standard_margin/i18n/product_standard_margin.pot b/product_standard_margin/i18n/product_standard_margin.pot
index 8c0b59d3a..25a492dce 100644
--- a/product_standard_margin/i18n/product_standard_margin.pot
+++ b/product_standard_margin/i18n/product_standard_margin.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 15.0\n"
+"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -14,6 +14,7 @@ msgstr ""
"Plural-Forms: \n"
#. module: product_standard_margin
+#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
#: model:ir.model.fields,help:product_standard_margin.field_product_template__standard_margin_rate
msgid ""
"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
@@ -31,21 +32,13 @@ msgid ""
msgstr ""
#. module: product_standard_margin
-#: model:ir.model.fields,help:product_standard_margin.field_product_product__standard_margin_rate
-msgid ""
-"Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product "
-"form (not based on historical values).Take care of tax include and exclude.."
-" If no sale price set, will display 999.0"
-msgstr ""
-
-#. module: product_standard_margin
-#: model:ir.model,name:product_standard_margin.model_product_product
+#: model:ir.model,name:product_standard_margin.model_product_template
msgid "Product"
msgstr ""
#. module: product_standard_margin
-#: model:ir.model,name:product_standard_margin.model_product_template
-msgid "Product Template"
+#: model:ir.model,name:product_standard_margin.model_product_product
+msgid "Product Variant"
msgstr ""
#. module: product_standard_margin
From ffdf5d78b48c8a48df6b0166600cc8d331324d82 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Wed, 21 Jun 2023 15:18:28 +0000
Subject: [PATCH 58/80] [UPD] README.rst
---
product_standard_margin/README.rst | 12 ++++++------
.../static/description/index.html | 8 ++++----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/product_standard_margin/README.rst b/product_standard_margin/README.rst
index 318b2bf6d..44d3b45e8 100644
--- a/product_standard_margin/README.rst
+++ b/product_standard_margin/README.rst
@@ -14,13 +14,13 @@ Product Margin and Margin Rate
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmargin--analysis-lightgray.png?logo=github
- :target: https://github.com/OCA/margin-analysis/tree/15.0/product_standard_margin
+ :target: https://github.com/OCA/margin-analysis/tree/16.0/product_standard_margin
:alt: OCA/margin-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/margin-analysis-15-0/margin-analysis-15-0-product_standard_margin
+ :target: https://translation.odoo-community.org/projects/margin-analysis-16-0/margin-analysis-16-0-product_standard_margin
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/132/15.0
+ :target: https://runbot.odoo-community.org/runbot/132/16.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -35,7 +35,7 @@ Margin :
Markup :
(Sale Price without tax - Standard Price) / Standard Price
-.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/15.0/product_standard_margin/static/description/product_form.png
+.. figure:: https://raw.githubusercontent.com/OCA/margin-analysis/16.0/product_standard_margin/static/description/product_form.png
**Note:**
@@ -63,7 +63,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -106,6 +106,6 @@ Current `maintainer `__:
|maintainer-legalsylvain|
-This module is part of the `OCA/margin-analysis `_ project on GitHub.
+This module is part of the `OCA/margin-analysis `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/product_standard_margin/static/description/index.html b/product_standard_margin/static/description/index.html
index 18c509a6d..5f11a2151 100644
--- a/product_standard_margin/static/description/index.html
+++ b/product_standard_margin/static/description/index.html
@@ -367,7 +367,7 @@ Product Margin and Margin Rate
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

Add 2 fields on the product form that compute the standard (or theorical)
margin and markup based on the current values of sale and standard price
present in the product form. We take care of taxe included or excluded.
@@ -377,7 +377,7 @@ Product Margin and Margin Rate
Markup :
(Sale Price without tax - Standard Price) / Standard Price
Note:
As this module will base his simple computation on sale and cost prices,
@@ -411,7 +411,7 @@
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
From 5a3c49958da4ad88ee375f0e72f7959f6bbf0b8a Mon Sep 17 00:00:00 2001
From: Hugo
Date: Mon, 24 Jul 2023 11:30:04 +0200
Subject: [PATCH 59/80] [FIX] product_standard_margin
---
product_standard_margin/views/view_product_product.xml | 8 ++++----
product_standard_margin/views/view_product_template.xml | 2 --
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/product_standard_margin/views/view_product_product.xml b/product_standard_margin/views/view_product_product.xml
index 1dd6b8991..6e7fa19bc 100644
--- a/product_standard_margin/views/view_product_product.xml
+++ b/product_standard_margin/views/view_product_product.xml
@@ -13,8 +13,8 @@
position="after"
>
-
-
+
+
@@ -28,8 +28,8 @@
-
-
+
+
diff --git a/product_standard_margin/views/view_product_template.xml b/product_standard_margin/views/view_product_template.xml
index 715e5c417..e86f6d63b 100644
--- a/product_standard_margin/views/view_product_template.xml
+++ b/product_standard_margin/views/view_product_template.xml
@@ -16,12 +16,10 @@
/>
From bc51c2d24499236a9a1a82c50573d23e4a9a4d25 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Mon, 24 Jul 2023 12:24:25 +0000
Subject: [PATCH 60/80] product_standard_margin 16.0.1.0.1
---
product_standard_margin/__manifest__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/product_standard_margin/__manifest__.py b/product_standard_margin/__manifest__.py
index 0c63670f7..53e3d3da6 100644
--- a/product_standard_margin/__manifest__.py
+++ b/product_standard_margin/__manifest__.py
@@ -5,7 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Product Margin and Margin Rate",
- "version": "16.0.1.0.0",
+ "version": "16.0.1.0.1",
"author": "Camptocamp,GRAP,Odoo Community Association (OCA)",
"category": "Product",
"depends": ["account"],
From ec991560166fcf339b536d690bcb8f9f2d47aa4d Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Sun, 3 Sep 2023 14:37:30 +0000
Subject: [PATCH 61/80] [UPD] README.rst
---
product_standard_margin/README.rst | 15 ++++---
.../static/description/index.html | 40 ++++++++++---------
2 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/product_standard_margin/README.rst b/product_standard_margin/README.rst
index 44d3b45e8..826b2b6a4 100644
--- a/product_standard_margin/README.rst
+++ b/product_standard_margin/README.rst
@@ -2,10 +2,13 @@
Product Margin and Margin Rate
==============================
-.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+..
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! source digest: sha256:596f5e3407803f321b8176d8a58bd820d13dcab26d4fa2fd4060b458399f0549
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
@@ -19,11 +22,11 @@ Product Margin and Margin Rate
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/margin-analysis-16-0/margin-analysis-16-0-product_standard_margin
:alt: Translate me on Weblate
-.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/132/16.0
- :alt: Try me on Runbot
+.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/margin-analysis&target_branch=16.0
+ :alt: Try me on Runboat
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|badge1| |badge2| |badge3| |badge4| |badge5|
Add 2 fields on the product form that compute the standard (or theorical)
margin and markup based on the current values of sale and standard price
@@ -62,7 +65,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
-If you spotted it first, help us smashing it by providing a detailed and welcomed
+If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback `_.
Do not contact contributors directly about support or help with technical issues.
diff --git a/product_standard_margin/static/description/index.html b/product_standard_margin/static/description/index.html
index 5f11a2151..7d2edc6c9 100644
--- a/product_standard_margin/static/description/index.html
+++ b/product_standard_margin/static/description/index.html
@@ -1,20 +1,20 @@
-
+
-
+
Product Margin and Margin Rate