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/models/pos_order.py b/pos_margin/models/pos_order.py
index e3f306bc..557b64a4 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),
+ })
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).
-
+
+