Sylvain LE GAL
8 years ago
13 changed files with 424 additions and 0 deletions
-
79pos_margin/README.rst
-
2pos_margin/__init__.py
-
22pos_margin/__manifest__.py
-
50pos_margin/i18n/es.po
-
49pos_margin/i18n/fr.po
-
47pos_margin/i18n/it.po
-
48pos_margin/i18n/nl_NL.po
-
41pos_margin/i18n/pos_margin.pot
-
3pos_margin/models/__init__.py
-
25pos_margin/models/pos_order.py
-
33pos_margin/models/pos_order_line.py
-
BINpos_margin/static/description/pos_order_form.png
-
25pos_margin/views/view_pos_order.xml
@ -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 |
|||
<https://github.com/OCA/pos/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. |
|||
|
@ -0,0 +1,2 @@ |
|||
# -#- coding: utf-8 -#- |
|||
from . import models |
@ -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, |
|||
} |
@ -0,0 +1,50 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * pos_margin |
|||
# |
|||
# Translators: |
|||
# OCA Transbot <transbot@odoo-community.org>, 2017 |
|||
# enjolras <yo@miguelrevilla.com>, 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 <yo@miguelrevilla.com>, 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" |
@ -0,0 +1,49 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * pos_margin |
|||
# |
|||
# Translators: |
|||
# OCA Transbot <transbot@odoo-community.org>, 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 <transbot@odoo-community.org>, 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 "" |
@ -0,0 +1,47 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * pos_margin |
|||
# |
|||
# Translators: |
|||
# Francesco Fresta <franco.fresta@gmail.com>, 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 <franco.fresta@gmail.com>, 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" |
@ -0,0 +1,48 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * pos_margin |
|||
# |
|||
# Translators: |
|||
# Peter Hageman <hageman.p@gmail.com>, 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 <hageman.p@gmail.com>, 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" |
@ -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 "" |
|||
|
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import pos_order |
|||
from . import pos_order_line |
@ -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')) |
@ -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) |
After Width: 776 | Height: 419 | Size: 28 KiB |
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="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). |
|||
--> |
|||
|
|||
<odoo> |
|||
|
|||
<record id="view_pos_order_form" model="ir.ui.view"> |
|||
<field name="model">pos.order</field> |
|||
<field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//group[@name='order_total']" position="after"> |
|||
<group name="margin"> |
|||
<field name="margin" widget='monetary'/> |
|||
</group> |
|||
</xpath> |
|||
<xpath expr="//field[@name='lines']/tree/field[@name='price_unit']" position="after"> |
|||
<field name="purchase_price"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue