diff --git a/pos_margin/README.rst b/pos_margin/README.rst new file mode 100644 index 00000000..79d89bcb --- /dev/null +++ b/pos_margin/README.rst @@ -0,0 +1,83 @@ +This module adds the 'Margin' on sales order. +============================================= + + +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +=================== +Margin on PoS order +=================== + +This module extends the functionality of point of sale to support margin on +pos orders. + +This gives the profitability by calculating the difference between the Unit +Price and Cost Price. + + +Usage +===== + +To use this module, you need to: + +#. Go to 'Point Of Sale' / 'Daily Operations' / 'Orders' +#. Open an order + +.. figure:: ./pos_margin/static/description/pos_order_form.png + :width: 800px + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/184/8.0 + + +Technical information +===================== + +This module is highly inspired from the module 'Sale Order Margin', by Odoo SA. + +Known issues / Roadmap +====================== + +* include extra reporting, using the new margin field. + +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 smash it by providing detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Sylvain LE GAL (https://twitter.com/legalsylvain) + +Funders +------- + +The development of this module has been financially supported by: + +* GRAP, Groupement Régional Alimentaire de Proximité (www.grap.coop) + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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 https://odoo-community.org. + diff --git a/pos_margin/__init__.py b/pos_margin/__init__.py new file mode 100644 index 00000000..402ac47e --- /dev/null +++ b/pos_margin/__init__.py @@ -0,0 +1,2 @@ +# -#- coding: utf-8 -#- +from . import models diff --git a/pos_margin/__openerp__.py b/pos_margin/__openerp__.py new file mode 100644 index 00000000..44a2f678 --- /dev/null +++ b/pos_margin/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2017 - 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': 'POS Margin', + 'version': '8.0.1.0.0', + 'category': 'Point Of Sale', + 'sequence': 1, + 'author': "GRAP," + "Odoo Community Association (OCA)", + 'summary': 'Margin on PoS Order', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'views/view_pos_order.xml', + ], + 'installable': True, +} diff --git a/pos_margin/i18n/fr.po b/pos_margin/i18n/fr.po new file mode 100644 index 00000000..9d984f17 --- /dev/null +++ b/pos_margin/i18n/fr.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_margin +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-10 09:02+0000\n" +"PO-Revision-Date: 2017-04-10 09:02+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: pos_margin +#: field:pos.order.line,purchase_price:0 +msgid "Cost Price" +msgstr "Prix de revient" + +#. module: pos_margin +#: help:pos.order,margin:0 +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,name:pos_margin.model_pos_order_line +msgid "Lines of Point of Sale" +msgstr "Lignes de Points de Vente" + +#. module: pos_margin +#: field:pos.order,margin:0 +#: field:pos.order.line,margin:0 +msgid "Margin" +msgstr "Marge" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order +msgid "Point of Sale" +msgstr "Point de Vente" + diff --git a/pos_margin/models/__init__.py b/pos_margin/models/__init__.py new file mode 100644 index 00000000..83e74821 --- /dev/null +++ b/pos_margin/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import pos_order +from . import pos_order_line diff --git a/pos_margin/models/pos_order.py b/pos_margin/models/pos_order.py new file mode 100644 index 00000000..c117c163 --- /dev/null +++ b/pos_margin/models/pos_order.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2017 - 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 api, fields, models +import openerp.addons.decimal_precision as dp + + +class PosOrder(models.Model): + _inherit = 'pos.order' + + # Columns Section + margin = fields.Float( + 'Margin', compute='_compute_margin', store=True, + digits_compute=dp.get_precision('Product Price'), + help="It gives profitability by calculating the difference between" + " the Unit Price and the cost price.") + + # Compute Section + @api.multi + @api.depends('lines.margin') + def _compute_margin(self): + for order in self: + order.margin = sum(order.mapped('lines.margin')) diff --git a/pos_margin/models/pos_order_line.py b/pos_margin/models/pos_order_line.py new file mode 100644 index 00000000..f50b7108 --- /dev/null +++ b/pos_margin/models/pos_order_line.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2017 - 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 api, fields, models +import openerp.addons.decimal_precision as dp + + +class PosOrderLine(models.Model): + _inherit = 'pos.order.line' + + # Columns Section + margin = fields.Float( + 'Margin', compute='_compute_multi_margin', store=True, + multi='multi_margin', + digits_compute=dp.get_precision('Product Price')) + + purchase_price = fields.Float( + 'Cost Price', compute='_compute_multi_margin', store=True, + multi='multi_margin', + digits_compute=dp.get_precision('Product Price')) + + # Compute Section + @api.multi + @api.depends('product_id', 'qty', 'price_subtotal') + def _compute_multi_margin(self): + for line in self: + if not line.product_id: + line.purchase_price = 0 + line.margin = 0 + else: + line.purchase_price = line.product_id.standard_price + line.margin = line.price_subtotal - ( + line.product_id.standard_price * line.qty) diff --git a/pos_margin/static/description/pos_order_form.png b/pos_margin/static/description/pos_order_form.png new file mode 100644 index 00000000..392b816a Binary files /dev/null and b/pos_margin/static/description/pos_order_form.png differ diff --git a/pos_margin/views/view_pos_order.xml b/pos_margin/views/view_pos_order.xml new file mode 100644 index 00000000..50b594a0 --- /dev/null +++ b/pos_margin/views/view_pos_order.xml @@ -0,0 +1,25 @@ + + + + + + + pos.order + + + + + + + + + + + + + +