Browse Source

new module pos_margin

pull/174/head
Sylvain LE GAL 8 years ago
parent
commit
0bddb001aa
  1. 83
      pos_margin/README.rst
  2. 2
      pos_margin/__init__.py
  3. 21
      pos_margin/__openerp__.py
  4. 43
      pos_margin/i18n/fr.po
  5. 3
      pos_margin/models/__init__.py
  6. 25
      pos_margin/models/pos_order.py
  7. 35
      pos_margin/models/pos_order_line.py
  8. BIN
      pos_margin/static/description/pos_order_form.png
  9. 25
      pos_margin/views/view_pos_order.xml

83
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
<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.

2
pos_margin/__init__.py

@ -0,0 +1,2 @@
# -#- coding: utf-8 -#-
from . import models

21
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,
}

43
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"

3
pos_margin/models/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import pos_order
from . import pos_order_line

25
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'))

35
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)

BIN
pos_margin/static/description/pos_order_form.png

After

Width: 776  |  Height: 419  |  Size: 28 KiB

25
pos_margin/views/view_pos_order.xml

@ -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).
-->
<openerp><data>
<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>
</data></openerp>
Loading…
Cancel
Save