diff --git a/pos_margin/README.rst b/pos_margin/README.rst new file mode 100644 index 00000000..4554966c --- /dev/null +++ b/pos_margin/README.rst @@ -0,0 +1,79 @@ +.. 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/__manifest__.py b/pos_margin/__manifest__.py new file mode 100644 index 00000000..7569aaa5 --- /dev/null +++ b/pos_margin/__manifest__.py @@ -0,0 +1,22 @@ +# -*- 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': '10.0.1.0.0', + 'category': 'Point Of Sale', + 'sequence': 1, + 'author': "GRAP," + "Odoo Community Association (OCA)", + 'summary': 'Margin on PoS Order', + 'license': 'AGPL-3', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'views/view_pos_order.xml', + ], + 'installable': True, +} diff --git a/pos_margin/i18n/es.po b/pos_margin/i18n/es.po new file mode 100644 index 00000000..8ab92724 --- /dev/null +++ b/pos_margin/i18n/es.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_margin +# +# Translators: +# OCA Transbot , 2017 +# enjolras , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-01 02:01+0000\n" +"PO-Revision-Date: 2018-03-01 02:01+0000\n" +"Last-Translator: enjolras , 2018\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\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: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_purchase_price +msgid "Cost Price" +msgstr "Precio de coste" + +#. 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 "" +"Indica el beneficio calculando la diferencia entre el precio unitario y el " +"precio de coste." + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order_line +msgid "Lines of Point of Sale" +msgstr "Líneas del punto de venta" + +#. module: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_margin +msgid "Margin" +msgstr "Margen" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order +msgid "Point of Sale Orders" +msgstr "Pedidos del TPV" diff --git a/pos_margin/i18n/fr.po b/pos_margin/i18n/fr.po new file mode 100644 index 00000000..b982c082 --- /dev/null +++ b/pos_margin/i18n/fr.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_margin +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-25 02:39+0000\n" +"PO-Revision-Date: 2017-04-25 02:39+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\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: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_purchase_price +msgid "Cost Price" +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." + +#. 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 +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_margin +msgid "Margin" +msgstr "Marge" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order +msgid "Point of Sale Orders" +msgstr "" diff --git a/pos_margin/i18n/it.po b/pos_margin/i18n/it.po new file mode 100644 index 00000000..69a4ed67 --- /dev/null +++ b/pos_margin/i18n/it.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_margin +# +# Translators: +# Francesco Fresta , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-01 02:01+0000\n" +"PO-Revision-Date: 2018-03-01 02:01+0000\n" +"Last-Translator: Francesco Fresta , 2018\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\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: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_purchase_price +msgid "Cost Price" +msgstr "" + +#. 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 "" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order_line +msgid "Lines of Point of Sale" +msgstr "" + +#. module: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_margin +msgid "Margin" +msgstr "Margine" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order +msgid "Point of Sale Orders" +msgstr "Punto di riordino" diff --git a/pos_margin/i18n/nl_NL.po b/pos_margin/i18n/nl_NL.po new file mode 100644 index 00000000..6d8cd895 --- /dev/null +++ b/pos_margin/i18n/nl_NL.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_margin +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-30 02:44+0000\n" +"PO-Revision-Date: 2017-05-30 02:44+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\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: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_purchase_price +msgid "Cost Price" +msgstr "Kostprijs" + +#. 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 "" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order_line +msgid "Lines of Point of Sale" +msgstr "" + +#. module: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_margin +msgid "Margin" +msgstr "Marge" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order +msgid "Point of Sale Orders" +msgstr "Kassaorders" diff --git a/pos_margin/i18n/pos_margin.pot b/pos_margin/i18n/pos_margin.pot new file mode 100644 index 00000000..b91d0ddb --- /dev/null +++ b/pos_margin/i18n/pos_margin.pot @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_margin +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.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: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_purchase_price +msgid "Cost Price" +msgstr "" + +#. 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 "" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order_line +msgid "Lines of Point of Sale" +msgstr "" + +#. module: pos_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_line_margin +#: model:ir.model.fields,field_description:pos_margin.field_pos_order_margin +msgid "Margin" +msgstr "" + +#. module: pos_margin +#: model:ir.model,name:pos_margin.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + 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..824da0b2 --- /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 odoo 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=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..ac18dece --- /dev/null +++ b/pos_margin/models/pos_order_line.py @@ -0,0 +1,33 @@ +# -*- 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 odoo 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=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')) + + # 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..190f6006 --- /dev/null +++ b/pos_margin/views/view_pos_order.xml @@ -0,0 +1,25 @@ + + + + + + + pos.order + + + + + + + + + + + + + +