Skip to content

Commit c7e1b22

Browse files
committed
[MIG] pos_payment_change: Migration to 17.0
1 parent ac8c084 commit c7e1b22

File tree

7 files changed

+84
-77
lines changed

7 files changed

+84
-77
lines changed

pos_payment_change/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44
{
55
"name": "Point Of Sale - Change Payments",
6-
"version": "16.0.1.0.4",
6+
"version": "17.0.1.0.0",
77
"summary": "Allow cashier to change order payments, as long as"
88
" the session is not closed.",
99
"category": "Point Of Sale",

pos_payment_change/static/description/index.html

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
/*
1010
:Author: David Goodger (goodger@python.org)
11-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1516
1617
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1718
customize this style sheet.
@@ -274,7 +275,7 @@
274275
margin-left: 2em ;
275276
margin-right: 2em }
276277

277-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
278279
pre.code, code { background-color: #eeeeee }
279280
pre.code .comment, code .comment { color: #5C6576 }
280281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@
300301
span.pre {
301302
white-space: pre }
302303

303-
span.problematic {
304+
span.problematic, pre.problematic {
304305
color: red }
305306

306307
span.section-subtitle {
@@ -368,12 +369,12 @@ <h1 class="title">Point Of Sale - Change Payments</h1>
368369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
369370
!! source digest: sha256:f92dd72ac053a86a8837e2a670cfa091391cadb66e6e3b45553b3b34f8d76400
370371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
371-
<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/16.0/pos_payment_change"><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-16-0/pos-16-0-pos_payment_change"><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=16.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/17.0/pos_payment_change"><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_payment_change"><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>
372373
<p>This module extends the functionnality of the Odoo Point of Sale to
373374
allow the cashier to change the payments of a PoS order.</p>
374375
<p>This feature is usefull when the user realized that he did a mistake,
375-
just after he marked the order as paid, or during the close of the session,
376-
Only if entries has not been generated.</p>
376+
just after he marked the order as paid, or during the close of the
377+
session, Only if entries has not been generated.</p>
377378
<p><strong>Table of contents</strong></p>
378379
<div class="contents local topic" id="contents">
379380
<ul class="simple">
@@ -394,22 +395,18 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
394395
<ul class="simple">
395396
<li>Go to Point of Sale.</li>
396397
<li>Choose the view list.</li>
397-
<li>Edit your point of sale, and select a value for the field
398-
‘Payment Change Policy’.</li>
398+
<li>Edit your point of sale, and select a value for the field ‘Payment
399+
Change Policy’.</li>
399400
</ul>
400401
<p>Two options are available:</p>
401402
<ul class="simple">
402-
<li>‘Refund and Resale’: Odoo will refund the current
403-
Pos Order to cancel it, and create a new PoS Order
404-
with the correct payment lines</li>
403+
<li>‘Refund and Resale’: Odoo will refund the current Pos Order to cancel
404+
it, and create a new PoS Order with the correct payment lines</li>
405405
<li>‘Update Payments’: Odoo will change payment lines.</li>
406406
</ul>
407-
<div class="figure">
408-
<img alt="https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_config_form.png" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_config_form.png" />
409-
</div>
410-
<p><strong>Note</strong>
411-
In some countries the ‘Update Payments’ Option
412-
is not allowed by law, because orders history shouldn’t not be altered.</p>
407+
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/pos/17.0/pos_payment_change/static/description/pos_config_form.png" /></p>
408+
<p><strong>Note</strong> In some countries the ‘Update Payments’ Option is not allowed
409+
by law, because orders history shouldn’t not be altered.</p>
413410
<p>For that purpose, a constrains is present to check the value of this
414411
field. If the module <tt class="docutils literal">l10n_fr_certification</tt> is installed and if the
415412
current company has an inalterable accounting, it will not be possible
@@ -421,32 +418,27 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
421418
<li>Go to a PoS Order</li>
422419
<li>Click on the button ‘Change Payments’</li>
423420
</ul>
424-
<div class="figure">
425-
<img alt="https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_order_form.png" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_order_form.png" />
426-
</div>
421+
<p><img alt="Button Change Payment" src="https://raw.githubusercontent.com/OCA/pos/17.0/pos_payment_change/static/description/pos_order_form.png" /></p>
427422
<ul class="simple">
428-
<li>In the pop up wizard, select the real payment(s) that have been
429-
used to pay the order</li>
423+
<li>In the pop up wizard, select the real payment(s) that have been used
424+
to pay the order</li>
430425
</ul>
431-
<div class="figure">
432-
<img alt="https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_payment_change_wizard_form.png" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_payment_change_wizard_form.png" />
433-
</div>
426+
<p><img alt="Button Open Wizard" src="https://raw.githubusercontent.com/OCA/pos/17.0/pos_payment_change/static/description/pos_payment_change_wizard_form.png" /></p>
434427
<ul class="simple">
435428
<li>Then click on the button ‘Change Payments’</li>
436429
</ul>
437430
<p><strong>Note</strong></p>
438-
<p>If the option ‘Refund and Resale’ is selected, changing the payments will
439-
display the three PoS orders. the oringal one, the refund one, and the new one.</p>
440-
<div class="figure">
441-
<img alt="https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_order_tree.png" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_payment_change/static/description/pos_order_tree.png" />
442-
</div>
431+
<p>If the option ‘Refund and Resale’ is selected, changing the payments
432+
will display the three PoS orders. the oringal one, the refund one, and
433+
the new one.</p>
434+
<p><img alt="New POS Payments Created" src="https://raw.githubusercontent.com/OCA/pos/17.0/pos_payment_change/static/description/pos_order_tree.png" /></p>
443435
</div>
444436
<div class="section" id="bug-tracker">
445437
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
446438
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
447439
In case of trouble, please check there if your issue has already been reported.
448440
If you spotted it first, help us to smash it by providing a detailed and welcomed
449-
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_payment_change%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
441+
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_payment_change%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
450442
<p>Do not contact contributors directly about support or help with technical issues.</p>
451443
</div>
452444
<div class="section" id="credits">
@@ -470,20 +462,23 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
470462
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
471463
<p>The development of this module has been financially supported by:</p>
472464
<ul class="simple">
473-
<li>GRAP, Groupement Régional Alimentaire de proximité (www.grap.coop)</li>
474-
<li>Vracoop (www.vracoop.fr)</li>
465+
<li>GRAP, Groupement Régional Alimentaire de proximité
466+
(<a class="reference external" href="http://www.grap.coop">www.grap.coop</a>)</li>
467+
<li>Vracoop (<a class="reference external" href="http://www.vracoop.fr">www.vracoop.fr</a>)</li>
475468
</ul>
476469
</div>
477470
<div class="section" id="maintainers">
478471
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
479472
<p>This module is maintained by the OCA.</p>
480-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
473+
<a class="reference external image-reference" href="https://odoo-community.org">
474+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
475+
</a>
481476
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
482477
mission is to support the collaborative development of Odoo features and
483478
promote its widespread use.</p>
484479
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
485480
<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>
486-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_payment_change">OCA/pos</a> project on GitHub.</p>
481+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/17.0/pos_payment_change">OCA/pos</a> project on GitHub.</p>
487482
<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>
488483
</div>
489484
</div>

pos_payment_change/views/view_pos_config.xml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,15 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
1010
<field name="model">pos.config</field>
1111
<field name="inherit_id" ref="point_of_sale.pos_config_view_form" />
1212
<field name="arch" type="xml">
13-
<xpath
14-
expr="//div[hasclass('o_settings_container')][2]/div"
15-
position="after"
16-
>
17-
<div class="col-12 col-lg-6 o_setting_box">
18-
<div class="o_setting_right_pane">
19-
<span class="o_form_label">Payment Change Policy</span>
20-
<div class="content-group mt16">
21-
<field
22-
name="payment_change_policy"
23-
colspan="4"
24-
nolabel="1"
25-
/>
26-
</div>
27-
</div>
28-
</div>
13+
<xpath expr="//setting[@id='other_devices']" position="before">
14+
<setting
15+
name="payment_change_policy_setting"
16+
string="Payment Change Policy"
17+
>
18+
<label for="payment_change_policy" class="col-lg-4 o_light_label" />
19+
<field name="payment_change_policy" />
20+
</setting>
21+
2922
</xpath>
3023
</field>
3124
</record>

pos_payment_change/views/view_pos_order.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
1313
<button name="refund" position="before">
1414
<button
1515
name="%(action_pos_payment_change_wizard)d"
16-
context="{'pos_session_id' : session_id}"
16+
context="{'pos_order_id' : id}"
1717
string="Change Payments"
1818
type="action"
19-
states="paid,invoiced"
19+
invisible="state not in ('paid', 'invoiced')"
2020
/>
2121
</button>
2222
</field>

pos_payment_change/wizards/pos_payment_change_wizard.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ class PosPaymentChangeWizard(models.TransientModel):
1212
_description = "PoS Payment Change Wizard"
1313

1414
# Column Section
15-
order_id = fields.Many2one(comodel_name="pos.order", string="Order", readonly=True)
15+
order_id = fields.Many2one(
16+
comodel_name="pos.order",
17+
string="Order",
18+
readonly=True,
19+
required=True,
20+
ondelete="cascade",
21+
)
1622

1723
old_line_ids = fields.One2many(
1824
comodel_name="pos.payment.change.wizard.old.line",
@@ -27,14 +33,16 @@ class PosPaymentChangeWizard(models.TransientModel):
2733
string="New Payment Lines",
2834
)
2935

30-
amount_total = fields.Float(string="Total", readonly=True)
36+
amount_total = fields.Float(
37+
string="Total", readonly=True, related="order_id.amount_total"
38+
)
3139

3240
# View Section
3341
@api.model
3442
def default_get(self, fields):
3543
PosOrder = self.env["pos.order"]
3644
res = super().default_get(fields)
37-
order = PosOrder.browse(self._context.get("active_id"))
45+
order = PosOrder.browse(self._context.get("pos_order_id"))
3846
old_lines_vals = []
3947
for payment in order.payment_ids:
4048
old_lines_vals.append(

pos_payment_change/wizards/pos_payment_change_wizard_new_line.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ class PosPaymentChangeWizardLine(models.TransientModel):
1919
comodel_name="pos.payment.method",
2020
string="Payment Method",
2121
required=True,
22-
domain=lambda s: s._domain_new_payment_method_id(),
22+
domain="[('id', 'in', available_payment_method_ids)]",
23+
)
24+
25+
available_payment_method_ids = fields.Many2many(
26+
comodel_name="pos.payment.method",
27+
string="Available Payment Methods",
28+
help="List of available payment methods for the current POS Order",
29+
compute="_compute_available_payment_method_ids",
2330
)
2431

2532
company_currency_id = fields.Many2one(
@@ -33,24 +40,22 @@ class PosPaymentChangeWizardLine(models.TransientModel):
3340

3441
amount = fields.Monetary(
3542
required=True,
36-
default=0.0,
3743
currency_field="company_currency_id",
44+
compute="_compute_amount",
45+
store=True,
46+
readonly=False,
3847
)
3948

40-
@api.model
41-
def _domain_new_payment_method_id(self):
42-
PosOrder = self.env["pos.order"]
43-
order = PosOrder.browse(self.env.context.get("active_id"))
44-
return [("id", "in", order.mapped("session_id.payment_method_ids").ids)]
45-
46-
# View Section
47-
@api.model
48-
def default_get(self, fields):
49-
res = super().default_get(fields)
50-
if "new_line_ids" not in self._context:
51-
return res
52-
balance = self._context.get("amount_total", 0.0)
53-
for line in self.wizard_id.old_line_ids:
54-
balance -= line.get("amount")
55-
res.update({"amount": balance})
56-
return res
49+
@api.depends("wizard_id")
50+
def _compute_available_payment_method_ids(self):
51+
for line in self:
52+
line.available_payment_method_ids = (
53+
line.wizard_id.order_id.session_id.payment_method_ids
54+
)
55+
56+
@api.depends("wizard_id")
57+
def _compute_amount(self):
58+
for line in self:
59+
line.amount = line.wizard_id.amount_total - sum(
60+
old_line.amount for old_line in line.wizard_id.old_line_ids
61+
)

pos_payment_change/wizards/view_pos_payment_change_wizard.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
1111
<field name="arch" type="xml">
1212
<form>
1313
<group col="4">
14-
<field name="order_id" />
14+
<field name="order_id" force_save="1" />
1515
<field name="amount_total" invisible="1" />
1616
<field name="old_line_ids" colspan="4">
1717
<tree>
1818
<field name="old_payment_method_id" widget="selection" />
19+
<field name="company_currency_id" column_invisible="1" />
1920
<field name="amount" sum="Total" />
2021
</tree>
2122
</field>
@@ -28,6 +29,11 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
2829
<tree editable="bottom">
2930
<field name="new_payment_method_id" widget="selection" />
3031
<field name="amount" sum="Total" />
32+
<field name="company_currency_id" column_invisible="1" />
33+
<field
34+
name="available_payment_method_ids"
35+
column_invisible="1"
36+
/>
3137
</tree>
3238
</field>
3339
</group>

0 commit comments

Comments
 (0)