Skip to content

Commit 1e4dc32

Browse files
committed
[MIG] pos_margin: Migration to 18.0
1 parent d0327d9 commit 1e4dc32

File tree

8 files changed

+76
-54
lines changed

8 files changed

+76
-54
lines changed

pos_margin/README.rst

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ PoS Order Margin
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
20-
:target: https://github.com/OCA/pos/tree/17.0/pos_margin
20+
:target: https://github.com/OCA/pos/tree/18.0/pos_margin
2121
:alt: OCA/pos
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_margin
23+
:target: https://translation.odoo-community.org/projects/pos-18-0/pos-18-0-pos_margin
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=17.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -38,13 +38,13 @@ This module shows margins in PoS frontend during an order creation.
3838
Configuration
3939
=============
4040

41-
- If you want to disable the display of the margin, in the front-office
42-
UI, you can uncheck the check box in the res.config.settings shop
43-
form:
41+
- If you want to disable the display of the margin, in the front-office
42+
UI, you can uncheck the check box in the res.config.settings shop
43+
form:
4444

4545
|image1|
4646

47-
.. |image1| image:: https://raw.githubusercontent.com/OCA/pos/17.0/pos_margin/static/description/pos_config_setting.png
47+
.. |image1| image:: https://raw.githubusercontent.com/OCA/pos/18.0/pos_margin/static/description/pos_config_setting.png
4848

4949
Usage
5050
=====
@@ -64,34 +64,34 @@ Changelog
6464
16.0.1.0.0
6565
----------
6666

67-
- Migrate to V16.0
68-
- Remove ``pos.order`` and ``pos.order.line`` funcionality from V14.0.
69-
It's already done by V16.0.
70-
- Remove tests.
71-
- Create a ``res.config.settings`` field pos_iface_display_margin to
72-
display margins in PoS frontend.
67+
- Migrate to V16.0
68+
- Remove ``pos.order`` and ``pos.order.line`` funcionality from V14.0.
69+
It's already done by V16.0.
70+
- Remove tests.
71+
- Create a ``res.config.settings`` field pos_iface_display_margin to
72+
display margins in PoS frontend.
7373

7474
14.0.1.0.0
7575
----------
7676

77-
- Migrate to V14.0
77+
- Migrate to V14.0
7878

7979
13.0.1.0.0
8080
----------
8181

82-
- Migrate to V13.0
83-
- Reuse ``sale_margin`` computation to handle multi currency context.
84-
- Correct computation of margin, if a module that adds ``uom_id`` on
85-
``pos.order.line`` is installed.
86-
- Add test
82+
- Migrate to V13.0
83+
- Reuse ``sale_margin`` computation to handle multi currency context.
84+
- Correct computation of margin, if a module that adds ``uom_id`` on
85+
``pos.order.line`` is installed.
86+
- Add test
8787

8888
Bug Tracker
8989
===========
9090

9191
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
9292
In case of trouble, please check there if your issue has already been reported.
9393
If you spotted it first, help us to smash it by providing a detailed and welcomed
94-
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_margin%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
94+
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_margin%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
9595

9696
Do not contact contributors directly about support or help with technical issues.
9797

@@ -107,12 +107,13 @@ Authors
107107
Contributors
108108
------------
109109

110-
- Sylvain LE GAL (https://twitter.com/legalsylvain)
111-
- Wolfgang Pichler
112-
- Murtaza Mithaiwala (https://twitter.com/MurtazaMithaiw4)
113-
- Dhara Solanki <dhara.solanki@initos.com>
114-
- Juan Carlos Bonilla <juancarlos.bonilla@factorlibre.com>
115-
- Antonio Ruban <antoniodavid8@gmail.com>
110+
- Sylvain LE GAL (https://twitter.com/legalsylvain)
111+
- Wolfgang Pichler
112+
- Murtaza Mithaiwala (https://twitter.com/MurtazaMithaiw4)
113+
- Dhara Solanki <dhara.solanki@initos.com>
114+
- Juan Carlos Bonilla <juancarlos.bonilla@factorlibre.com>
115+
- Antonio Ruban <antoniodavid8@gmail.com>
116+
- Alberto Martínez <alberto.martinez@sygel.es>
116117

117118
Maintainers
118119
-----------
@@ -135,6 +136,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
135136

136137
|maintainer-legalsylvain|
137138

138-
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/17.0/pos_margin>`_ project on GitHub.
139+
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/18.0/pos_margin>`_ project on GitHub.
139140

140141
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

pos_margin/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "PoS Order Margin",
77
"summary": "Margin on PoS Order",
8-
"version": "17.0.1.0.0",
8+
"version": "18.0.1.0.0",
99
"category": "Point Of Sale",
1010
"author": "GRAP, FactorLibre, Odoo Community Association (OCA)",
1111
"maintainers": ["legalsylvain"],

pos_margin/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
- Dhara Solanki \<dhara.solanki@initos.com\>
55
- Juan Carlos Bonilla \<juancarlos.bonilla@factorlibre.com\>
66
- Antonio Ruban \<antoniodavid8@gmail.com\>
7+
- Alberto Martínez \<alberto.martinez@sygel.es\>

pos_margin/report/pos_order_report.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def _select(self):
1414
return (
1515
super()._select()
1616
+ """,
17-
SUM(
17+
(
1818
l.price_subtotal - l.total_cost /
1919
CASE COALESCE(s.currency_rate, 0)
2020
WHEN 0 THEN 1.0
2121
ELSE s.currency_rate
2222
END
23-
) / NULLIF(SUM(l.price_subtotal), 0) * 100
24-
AS margin_rate
23+
) / NULLIF(l.price_subtotal, 0) * 100
24+
AS margin_rate
2525
"""
2626
)
2727

pos_margin/static/description/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ <h1 class="title">PoS Order Margin</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:5efe86f27e3f8a6c1fa3ea8fa60ee57d4c767bb29d04edc3c284a0b5baa6ede9
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/17.0/pos_margin"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_margin"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/pos/tree/18.0/pos_margin"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/pos-18-0/pos-18-0-pos_margin"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/pos&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module shows margins in PoS frontend during an order creation.</p>
374374
<p><strong>Table of contents</strong></p>
375375
<div class="contents local topic" id="contents">
@@ -399,7 +399,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
399399
UI, you can uncheck the check box in the res.config.settings shop
400400
form:</li>
401401
</ul>
402-
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/pos/17.0/pos_margin/static/description/pos_config_setting.png" /></p>
402+
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/pos/18.0/pos_margin/static/description/pos_config_setting.png" /></p>
403403
</div>
404404
<div class="section" id="usage">
405405
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
@@ -445,7 +445,7 @@ <h1><a class="toc-backref" href="#toc-entry-8">Bug Tracker</a></h1>
445445
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
446446
In case of trouble, please check there if your issue has already been reported.
447447
If you spotted it first, help us to smash it by providing a detailed and welcomed
448-
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_margin%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
448+
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_margin%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
449449
<p>Do not contact contributors directly about support or help with technical issues.</p>
450450
</div>
451451
<div class="section" id="credits">
@@ -466,6 +466,7 @@ <h2><a class="toc-backref" href="#toc-entry-11">Contributors</a></h2>
466466
<li>Dhara Solanki &lt;<a class="reference external" href="mailto:dhara.solanki&#64;initos.com">dhara.solanki&#64;initos.com</a>&gt;</li>
467467
<li>Juan Carlos Bonilla &lt;<a class="reference external" href="mailto:juancarlos.bonilla&#64;factorlibre.com">juancarlos.bonilla&#64;factorlibre.com</a>&gt;</li>
468468
<li>Antonio Ruban &lt;<a class="reference external" href="mailto:antoniodavid8&#64;gmail.com">antoniodavid8&#64;gmail.com</a>&gt;</li>
469+
<li>Alberto Martínez &lt;<a class="reference external" href="mailto:alberto.martinez&#64;sygel.es">alberto.martinez&#64;sygel.es</a>&gt;</li>
469470
</ul>
470471
</div>
471472
<div class="section" id="maintainers">
@@ -479,7 +480,7 @@ <h2><a class="toc-backref" href="#toc-entry-12">Maintainers</a></h2>
479480
promote its widespread use.</p>
480481
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
481482
<p><a class="reference external image-reference" href="https://github.com/legalsylvain"><img alt="legalsylvain" src="https://github.com/legalsylvain.png?size=40px" /></a></p>
482-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/17.0/pos_margin">OCA/pos</a> project on GitHub.</p>
483+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/18.0/pos_margin">OCA/pos</a> project on GitHub.</p>
483484
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
484485
</div>
485486
</div>

pos_margin/static/src/js/OrderSummaryMargin.esm.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** @odoo-module **/
21
// Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
32
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
43
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
/** @odoo-module **/
21
// Copyright (C) 2023 - Today: GRAP (http://www.grap.coop)
32
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
43
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
54

6-
import {Order, Orderline} from "@point_of_sale/app/store/models";
5+
import {Orderline} from "@point_of_sale/app/generic_components/orderline/orderline";
6+
import {PosOrder} from "@point_of_sale/app/models/pos_order";
7+
import {PosOrderline} from "@point_of_sale/app/models/pos_order_line";
78
import {patch} from "@web/core/utils/patch";
9+
import {roundCurrency} from "@point_of_sale/app/models/utils/currency";
810

911
// /////////////////////////////
10-
// Overload models.Order
12+
// Overload models.PosOrder
1113
// /////////////////////////////
12-
patch(Order.prototype, {
14+
patch(PosOrder.prototype, {
1315
get_margin() {
1416
return this.get_orderlines().reduce(
1517
(margin, line) => margin + line.get_margin(),
@@ -22,18 +24,14 @@ patch(Order.prototype, {
2224
},
2325

2426
get_margin_rate_str() {
25-
return this.env.utils.roundCurrency(this.get_margin_rate()) + "%";
27+
return roundCurrency(this.get_margin_rate(), this.currency) + "%";
2628
},
2729
});
2830

2931
// /////////////////////////////
30-
// Overload models.OrderLine
32+
// Overload models.PosOrderline
3133
// /////////////////////////////
32-
patch(Orderline.prototype, {
33-
setup() {
34-
super.setup(...arguments);
35-
console.log(this.pos);
36-
},
34+
patch(PosOrderline.prototype, {
3735
getDisplayData() {
3836
return {
3937
...super.getDisplayData(),
@@ -43,23 +41,37 @@ patch(Orderline.prototype, {
4341
};
4442
},
4543
get_iface_display_margin() {
46-
return this.pos.config.iface_display_margin;
44+
return this.config.iface_display_margin;
4745
},
4846
get_purchase_price() {
4947
// Overload the function to use another field that the default standard_price
50-
return this.product.standard_price;
48+
return this.product_id.standard_price;
5149
},
5250
get_margin() {
5351
return (
54-
this.get_all_prices().priceWithoutTax -
55-
this.quantity * this.get_purchase_price()
52+
this.get_all_prices().priceWithoutTax - this.qty * this.get_purchase_price()
5653
);
5754
},
5855
get_margin_rate() {
5956
const priceWithoutTax = this.get_all_prices().priceWithoutTax;
6057
return priceWithoutTax ? (this.get_margin() / priceWithoutTax) * 100 : 0;
6158
},
6259
get_margin_rate_str() {
63-
return this.env.utils.roundCurrency(this.get_margin_rate()) + "%";
60+
return roundCurrency(this.get_margin_rate(), this.currency) + "%";
61+
},
62+
});
63+
64+
patch(Orderline, {
65+
props: {
66+
...Orderline.props,
67+
line: {
68+
...Orderline.props.line,
69+
shape: {
70+
...Orderline.props.line.shape,
71+
ifaceDisplayMargin: {type: Boolean, optional: true},
72+
margin_rate: {type: Number, optional: true},
73+
margin_rate_str: {type: String, optional: true},
74+
},
75+
},
6476
},
6577
});

pos_margin/views/res_config_settings_view.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
99
<field name="model">res.config.settings</field>
1010
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form" />
1111
<field name="arch" type="xml">
12-
<xpath expr="//field[@name='module_loyalty']/../.." position="after">
12+
<xpath expr="//setting[@id='pos-loyalty']" position="after">
13+
<setting
14+
id="order_margin"
15+
help="Display Margin and Margin Rate in the frontend"
16+
>
17+
<field name="pos_iface_display_margin" />
18+
</setting>
19+
</xpath>
20+
<!-- <xpath expr="//field[@name='module_loyalty']/../.." position="after">
1321
<div class="col-xs-12 col-lg-6 o_setting_box" id="order_margin">
1422
<div class="o_setting_left_pane">
1523
<field name="pos_iface_display_margin" />
@@ -21,7 +29,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
2129
</div>
2230
</div>
2331
</div>
24-
</xpath>
32+
</xpath> -->
2533
</field>
2634
</record>
2735
</odoo>

0 commit comments

Comments
 (0)