Sylvain LE GAL
5 years ago
15 changed files with 183 additions and 144 deletions
-
83pos_margin/README.rst
-
9pos_margin/__manifest__.py
-
54pos_margin/i18n/fr.po
-
29pos_margin/i18n/pos_margin.pot
-
2pos_margin/models/pos_order.py
-
28pos_margin/models/pos_order_line.py
-
2pos_margin/readme/CONTRIBUTORS.rst
-
5pos_margin/readme/DESCRIPTION.rst
-
8pos_margin/readme/HISTORY.rst
-
7pos_margin/readme/ROADMAP.rst
-
7pos_margin/readme/USAGE.rst
-
BINpos_margin/static/description/pos_order_form.png
-
1pos_margin/tests/__init__.py
-
68pos_margin/tests/test_module.py
-
20pos_margin/views/view_pos_order.xml
@ -1,79 +1,4 @@ |
|||||
.. 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. |
|
||||
|
|
||||
|
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||||
|
!! This file is generated by oca-gen-addon-readme !! |
||||
|
!! changes will be overwritten. !! |
||||
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
@ -0,0 +1,2 @@ |
|||||
|
* Sylvain LE GAL (https://twitter.com/legalsylvain) |
||||
|
* Wolfgang Pichler |
@ -0,0 +1,5 @@ |
|||||
|
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. |
@ -0,0 +1,8 @@ |
|||||
|
12.0.1.0.0 |
||||
|
~~~~~~~~~~ |
||||
|
|
||||
|
* Migrate to V12.0 |
||||
|
* Reuse ``sale_margin`` computation to handle multi currency context. |
||||
|
* Correct computation of margin, if a module that adds ``uom_id`` on |
||||
|
``pos.order.line`` is installed. |
||||
|
* Add test |
@ -0,0 +1,7 @@ |
|||||
|
This module depends on ``sale_margin`` module to reuse algorithm present in the |
||||
|
function ``_get_purchase_price`` of the model ``sale.order.line`` to |
||||
|
compute correctly purchase price, in a multicurrency context. |
||||
|
|
||||
|
This dependency can be removed, when Odoo Core will be correctly refactored, |
||||
|
moving this ``@api.model`` function in a more generic module (``account`` |
||||
|
for exemple). |
@ -0,0 +1,7 @@ |
|||||
|
To use this module, you need to: |
||||
|
|
||||
|
* Go to 'Point Of Sale' / 'Orders' / 'Orders' |
||||
|
* Open an order |
||||
|
|
||||
|
.. figure:: ../static/description/pos_order_form.png |
||||
|
:width: 800px |
Before Width: 776 | Height: 419 | Size: 28 KiB After Width: 896 | Height: 379 | Size: 30 KiB |
@ -0,0 +1 @@ |
|||||
|
from . import test_module |
@ -0,0 +1,68 @@ |
|||||
|
# Copyright 2019 - Today Sylvain LE GAL (https://twitter.com/legalsylvain) |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from odoo import fields |
||||
|
from odoo.tests.common import TransactionCase |
||||
|
|
||||
|
|
||||
|
class TestModule(TransactionCase): |
||||
|
|
||||
|
def setUp(self): |
||||
|
super(TestModule, self).setUp() |
||||
|
self.PosOrder = self.env['pos.order'] |
||||
|
self.pos_product = self.env.ref('point_of_sale.whiteboard_pen') |
||||
|
self.pricelist = self.env.ref('product.list0') |
||||
|
|
||||
|
# Create a new pos config and open it |
||||
|
self.pos_config = self.env.ref('point_of_sale.pos_config_main').copy() |
||||
|
self.pos_config.open_session_cb() |
||||
|
|
||||
|
def test_margin(self): |
||||
|
self.pos_product.list_price = 1.8 |
||||
|
self.pos_product.standard_price = 0.5 |
||||
|
order = self._create_order() |
||||
|
|
||||
|
self.assertEqual( |
||||
|
order.margin, 10 * (1.8 - 0.5), |
||||
|
"Bad computation of margin") |
||||
|
|
||||
|
def _create_order(self): |
||||
|
# Create order |
||||
|
order_data = { |
||||
|
'id': u'0006-001-0010', |
||||
|
'to_invoice': False, |
||||
|
'data': { |
||||
|
'pricelist_id': self.pricelist.id, |
||||
|
'user_id': 1, |
||||
|
'name': 'Order 0006-001-0010', |
||||
|
'partner_id': False, |
||||
|
'amount_paid': 0.9, |
||||
|
'pos_session_id': self.pos_config.current_session_id.id, |
||||
|
'lines': [[0, 0, { |
||||
|
'product_id': self.pos_product.id, |
||||
|
'price_unit': self.pos_product.list_price, |
||||
|
'qty': 10, |
||||
|
'price_subtotal': 18.0, |
||||
|
'price_subtotal_incl': 18.0, |
||||
|
}]], |
||||
|
'statement_ids': [[0, 0, { |
||||
|
'journal_id': self.pos_config.journal_ids[0].id, |
||||
|
'amount': 18.0, |
||||
|
'name': fields.Datetime.now(), |
||||
|
'account_id': |
||||
|
self.env.user.partner_id.property_account_receivable_id.id, |
||||
|
'statement_id': |
||||
|
self.pos_config.current_session_id.statement_ids[0].id, |
||||
|
}]], |
||||
|
'creation_date': u'2018-09-27 15:51:03', |
||||
|
'amount_tax': 0, |
||||
|
'fiscal_position_id': False, |
||||
|
'uid': u'00001-001-0001', |
||||
|
'amount_return': 0, |
||||
|
'sequence_number': 1, |
||||
|
'amount_total': 18.0, |
||||
|
}} |
||||
|
|
||||
|
result = self.PosOrder.create_from_ui([order_data]) |
||||
|
order = self.PosOrder.browse(result[0]) |
||||
|
return order |
Write
Preview
Loading…
Cancel
Save
Reference in new issue