diff --git a/pos_margin/__manifest__.py b/pos_margin/__manifest__.py
index 38502c1b..95ec672b 100644
--- a/pos_margin/__manifest__.py
+++ b/pos_margin/__manifest__.py
@@ -9,6 +9,7 @@
'category': 'Point Of Sale',
'author': "GRAP,"
"Odoo Community Association (OCA)",
+ "maintainers": ["legalsylvain"],
'website': 'https://github.com/OCA/pos',
'license': 'AGPL-3',
'depends': [
diff --git a/pos_margin/i18n/fr.po b/pos_margin/i18n/fr.po
index 8cf4d09e..a3161477 100644
--- a/pos_margin/i18n/fr.po
+++ b/pos_margin/i18n/fr.po
@@ -6,11 +6,10 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-08-15 11:05+0000\n"
-"PO-Revision-Date: 2019-08-15 11:05+0000\n"
+"POT-Creation-Date: 2019-12-12 10:19+0000\n"
+"PO-Revision-Date: 2019-12-12 10:19+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"
@@ -23,12 +22,8 @@ msgstr "Prix de revient"
#. module: pos_margin
#: model:ir.model.fields,help:pos_margin.field_pos_order__margin
-msgid ""
-"It gives profitability by calculating the difference between the Unit Price "
-"and the cost price."
-msgstr ""
-"Il donne la rentabilité en calculant la différence entre le prix unitaire et "
-"le prix de revient."
+msgid "It gives profitability by calculating the difference between the Unit Price and the cost price."
+msgstr "Il donne la rentabilité en calculant la différence entre le prix unitaire et le prix de revient."
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_pos_order__margin
@@ -36,6 +31,12 @@ msgstr ""
msgid "Margin"
msgstr "Marge"
+#. module: pos_margin
+#: model:ir.model.fields,field_description:pos_margin.field_pos_order__margin_percent
+#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line__margin_percent
+msgid "Margin (%)"
+msgstr "Marge (%)"
+
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate
msgid "Margin Rate"
@@ -43,7 +44,6 @@ msgstr "Taux de marque"
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_total
-#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree
msgid "Margin Total"
msgstr "Marge Totale"
@@ -60,4 +60,10 @@ msgstr "Commandes du point de vente"
#. module: pos_margin
#: model:ir.model,name:pos_margin.model_report_pos_order
msgid "Point of Sale Orders Report"
-msgstr ""
+msgstr "Rapport sur les commandes au point de vente"
+
+#. module: pos_margin
+#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree
+msgid "Total"
+msgstr "Total"
+
diff --git a/pos_margin/i18n/pos_margin.pot b/pos_margin/i18n/pos_margin.pot
index db529121..6be334b4 100644
--- a/pos_margin/i18n/pos_margin.pot
+++ b/pos_margin/i18n/pos_margin.pot
@@ -1,11 +1,13 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * pos_margin
+# * pos_margin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2019-12-12 10:18+0000\n"
+"PO-Revision-Date: 2019-12-12 10:18+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -29,6 +31,12 @@ msgstr ""
msgid "Margin"
msgstr ""
+#. module: pos_margin
+#: model:ir.model.fields,field_description:pos_margin.field_pos_order__margin_percent
+#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line__margin_percent
+msgid "Margin (%)"
+msgstr ""
+
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_rate
msgid "Margin Rate"
@@ -36,7 +44,6 @@ msgstr ""
#. module: pos_margin
#: model:ir.model.fields,field_description:pos_margin.field_report_pos_order__margin_total
-#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree
msgid "Margin Total"
msgstr ""
@@ -55,3 +62,8 @@ msgstr ""
msgid "Point of Sale Orders Report"
msgstr ""
+#. module: pos_margin
+#: model_terms:ir.ui.view,arch_db:pos_margin.view_pos_order_tree
+msgid "Total"
+msgstr ""
+
diff --git a/pos_margin/models/pos_order.py b/pos_margin/models/pos_order.py
index e3f306bc..f4157ad9 100644
--- a/pos_margin/models/pos_order.py
+++ b/pos_margin/models/pos_order.py
@@ -11,14 +11,29 @@ class PosOrder(models.Model):
# Columns Section
margin = fields.Float(
- 'Margin', compute='_compute_margin', store=True,
+ string='Margin',
+ compute='_compute_margin',
+ store=True,
digits=dp.get_precision('Product Price'),
help="It gives profitability by calculating the difference between"
" the Unit Price and the cost price.")
+ margin_percent = fields.Float(
+ string='Margin (%)',
+ compute='_compute_margin',
+ store=True,
+ digits=dp.get_precision('Product Price'),
+ )
+
# Compute Section
@api.multi
- @api.depends('lines.margin')
+ @api.depends('lines.margin', 'lines.price_subtotal')
def _compute_margin(self):
for order in self:
- order.margin = sum(order.mapped('lines.margin'))
+ tmp_margin = sum(order.mapped('lines.margin'))
+ tmp_price_subtotal = sum(order.mapped('lines.price_subtotal'))
+ order.update({
+ 'margin': tmp_margin,
+ 'margin_percent': tmp_price_subtotal and (
+ tmp_margin / tmp_price_subtotal * 100) or 0.0,
+ })
diff --git a/pos_margin/models/pos_order_line.py b/pos_margin/models/pos_order_line.py
index 9cb14f33..3bd46ead 100644
--- a/pos_margin/models/pos_order_line.py
+++ b/pos_margin/models/pos_order_line.py
@@ -11,12 +11,25 @@ class PosOrderLine(models.Model):
# Columns Section
margin = fields.Float(
- 'Margin', compute='_compute_multi_margin', store=True,
- multi='multi_margin', digits=dp.get_precision('Product Price'))
+ string='Margin',
+ compute='_compute_multi_margin',
+ store=True,
+ digits=dp.get_precision('Product Price'),
+ )
+
+ margin_percent = fields.Float(
+ string='Margin (%)',
+ compute='_compute_multi_margin',
+ store=True,
+ digits=dp.get_precision('Product Price'),
+ )
purchase_price = fields.Float(
- 'Cost Price', compute='_compute_multi_margin', store=True,
- multi='multi_margin', digits=dp.get_precision('Product Price'))
+ string='Cost Price',
+ compute='_compute_multi_margin',
+ store=True,
+ digits=dp.get_precision('Product Price'),
+ )
# Compute Section
@api.multi
@@ -24,8 +37,13 @@ class PosOrderLine(models.Model):
def _compute_multi_margin(self):
for line in self.filtered('product_id'):
purchase_price = self._get_purchase_price(line)
- line.purchase_price = purchase_price
- line.margin = line.price_subtotal - (purchase_price * line.qty)
+ margin = line.price_subtotal - (purchase_price * line.qty)
+ line.update({
+ 'purchase_price': purchase_price,
+ 'margin': margin,
+ 'margin_percent': line.price_subtotal and (
+ margin / line.price_subtotal * 100.0),
+ })
@api.model
def _get_purchase_price(self, line):
diff --git a/pos_margin/readme/USAGE.rst b/pos_margin/readme/USAGE.rst
index e719a37a..6d342a5e 100644
--- a/pos_margin/readme/USAGE.rst
+++ b/pos_margin/readme/USAGE.rst
@@ -1,7 +1,13 @@
To use this module, you need to:
* Go to 'Point Of Sale' / 'Orders' / 'Orders'
+
+.. figure:: ../static/description/pos_order_tree.png
+ :width: 800px
+
+
* Open an order
.. figure:: ../static/description/pos_order_form.png
:width: 800px
+
diff --git a/pos_margin/static/description/pos_order_form.png b/pos_margin/static/description/pos_order_form.png
index 22601768..1ff9c314 100644
Binary files a/pos_margin/static/description/pos_order_form.png and b/pos_margin/static/description/pos_order_form.png differ
diff --git a/pos_margin/static/description/pos_order_tree.png b/pos_margin/static/description/pos_order_tree.png
new file mode 100644
index 00000000..f65204fe
Binary files /dev/null and b/pos_margin/static/description/pos_order_tree.png differ
diff --git a/pos_margin/views/view_pos_order.xml b/pos_margin/views/view_pos_order.xml
index 75d24452..86797b70 100644
--- a/pos_margin/views/view_pos_order.xml
+++ b/pos_margin/views/view_pos_order.xml
@@ -13,9 +13,12 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
-
+
+
+
@@ -25,7 +28,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
+
+