Skip to content

Commit fa0c1c5

Browse files
committed
[FIX] fix and improve multiple things
* replace the donation.donation.pos_payment_ids field by pos_payment_method_ids to be able to access the pos payment methods directly. * fix donation creation error: the code was trying to store pos.payment.method ids in a many2many to pos.payment. * make donation.donation.pos_payment_method_ids a computed field. * avoid error in pos if no partner is selected. * remove useless code. * rename "POS" to "PoS" in multiple places. * update i18n files. * update readme.
1 parent a185d6b commit fa0c1c5

File tree

14 files changed

+165
-141
lines changed

14 files changed

+165
-141
lines changed

pos_donation/README.rst

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
============
2-
POS Donation
2+
PoS Donation
33
============
44

55
..
@@ -28,15 +28,31 @@ POS Donation
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

31-
When a donation product is sold in the POS, this module creates a
32-
donation related to the POS Order in draft state. This donation can be
33-
validated in order to generate a tax receipt for this donation.
31+
When a donation product is sold in the PoS, this module creates a donation related to the PoS order and validates it.
3432

3533
**Table of contents**
3634

3735
.. contents::
3836
:local:
3937

38+
Usage
39+
=====
40+
41+
To create donations from the PoS, a donation product must be sold.
42+
This product must have the "Donation in PoS" product type.
43+
This is important: the normal "Donation" product type will not work, as this would generate accounting entries two times.
44+
45+
The price of the product on the PoS order line defines the price of the donation.
46+
47+
Known issues / Roadmap
48+
======================
49+
50+
* If there is no partner set on the PoS order, a donation is not created.
51+
There should be a user warning in the PoS to avoid this.
52+
* If there are multiple donation products used in the same PoS order, a donation is not created.
53+
This is because the ``default_tax_receipt_option`` is currently defined on the ``product.template``.
54+
It would be better to define it on on a more global record, like the ``pos.config``.
55+
4056
Bug Tracker
4157
===========
4258

pos_donation/__manifest__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# SPDX-License-Identifier: AGPL-3.0-or-later
44

55
{
6-
"name": "POS Donation",
7-
"summary": "Generate donation for donation sold in POS.",
6+
"name": "PoS Donation",
7+
"summary": "Generate donation for donation sold in PoS",
88
"version": "16.0.1.0.0",
9-
"category": "POS",
9+
"category": "Sales/Point of Sale",
1010
"website": "https://github.com/OCA/pos",
1111
"author": "Coop IT Easy SC, Odoo Community Association (OCA)",
1212
"maintainers": ["remytms"],

pos_donation/demo/donation.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
<field name="default_code">POS-DON</field>
66
<field name="categ_id" ref="product.product_category_5" />
77
<field name="sale_ok" eval="True" />
8-
<field name="tax_receipt_ok" eval="True" />
98
<field name="list_price">0</field>
10-
<field name="detailed_type">donation_in_pos</field>
119
<field name="taxes_id" eval="False" />
10+
<field name="detailed_type">donation_in_pos</field>
11+
<field name="tax_receipt_ok" eval="True" />
12+
<field name="available_in_pos">True</field>
13+
<field name="default_tax_receipt_option">none</field>
1214
<field
1315
name="description"
14-
>This donation item that can be sold in POS and is eligible for a tax receipt.</field>
16+
>Donation item that can be sold in PoS and that is eligible for a tax receipt</field>
1517
</record>
1618
</odoo>

pos_donation/i18n/fr.po

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ msgstr ""
1010
"PO-Revision-Date: 2025-07-13 07:27+0000\n"
1111
"Last-Translator: Simon Hick\n"
1212
"Language-Team: \n"
13+
"Language: fr\n"
1314
"MIME-Version: 1.0\n"
1415
"Content-Type: text/plain; charset=UTF-8\n"
1516
"Content-Transfer-Encoding: \n"
@@ -19,7 +20,8 @@ msgstr ""
1920
#: model:ir.model.fields,help:pos_donation.field_product_product__detailed_type
2021
#: model:ir.model.fields,help:pos_donation.field_product_template__detailed_type
2122
msgid ""
22-
"A storable product is a product for which you manage stock. The Inventory app has to be installed.\n"
23+
"A storable product is a product for which you manage stock. The Inventory "
24+
"app has to be installed.\n"
2325
"A consumable product is a product for which stock is not managed.\n"
2426
"A service is a non-material product you provide."
2527
msgstr ""
@@ -47,9 +49,16 @@ msgstr ""
4749

4850
#. module: pos_donation
4951
#: model:ir.model.fields.selection,name:pos_donation.selection__product_template__detailed_type__donation_in_pos
50-
msgid "Donation in POS"
52+
msgid "Donation in PoS"
5153
msgstr ""
5254

55+
#. module: pos_donation
56+
#: model_terms:product.template,description:pos_donation.product_product_donation_pos_product_template
57+
msgid ""
58+
"Donation item that can be sold in PoS and that is eligible for a tax receipt"
59+
msgstr ""
60+
"Don qui peut être vendu en PdV et qui est éligible pour un reçu fiscal"
61+
5362
#. module: pos_donation
5463
#: model:ir.model.fields.selection,name:pos_donation.selection__product_template__default_tax_receipt_option__each
5564
msgid "For Each Donation"
@@ -60,34 +69,28 @@ msgstr ""
6069
msgid "None"
6170
msgstr ""
6271

72+
#. module: pos_donation
73+
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__displayed_payment_mode
74+
msgid "Payment Mode"
75+
msgstr ""
76+
6377
#. module: pos_donation
6478
#: model:product.template,name:pos_donation.product_product_donation_pos_product_template
65-
msgid "POS Donation"
79+
msgid "PoS Donation"
6680
msgstr ""
6781

6882
#. module: pos_donation
6983
#. odoo-python
7084
#: code:addons/pos_donation/models/donation.py:0
71-
#: code:addons/pos_donation/models/donation.py:0
72-
#: code:addons/src/oca/pos/pos_donation/models/donation.py:0
85+
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__pos_order_id
7386
#: model_terms:ir.ui.view,arch_db:pos_donation.donation_form
7487
#, python-format
75-
msgid "POS Order"
76-
msgstr ""
77-
78-
#. module: pos_donation
79-
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__displayed_payment_mode
80-
msgid "Payment Mode"
81-
msgstr ""
82-
83-
#. module: pos_donation
84-
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__pos_order_id
8588
msgid "PoS Order"
8689
msgstr ""
8790

8891
#. module: pos_donation
89-
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__pos_payment_ids
90-
msgid "PoS payment methods"
92+
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__pos_payment_method_ids
93+
msgid "PoS Payment Methods"
9194
msgstr ""
9295

9396
#. module: pos_donation
@@ -106,28 +109,13 @@ msgstr ""
106109
msgid "Product Type"
107110
msgstr ""
108111

109-
#. module: pos_donation
110-
#. odoo-python
111-
#: code:addons/pos_donation/models/product_template.py:0
112-
#: code:addons/pos_donation/models/product_template.py:0
113-
#: code:addons/src/oca/pos/pos_donation/models/product_template.py:0
114-
#: model:ir.model.constraint,message:pos_donation.constraint_product_template_check_company_id_for_donation_in_pos
115-
#, python-format
116-
msgid ""
117-
"Product for donation in pos must belong to a company."
118-
msgstr "Un produit représentant une donation doit appartenir à une entreprise"
119-
120-
#. module: pos_donation
121-
#: model_terms:product.template,description:pos_donation.product_product_donation_pos_product_template
122-
msgid ""
123-
"This donation item that can be sold in POS and is eligible for a tax "
124-
"receipt."
125-
msgstr "Ce produit est une donation, il peut être vendu en PdV et est éligible "
126-
"pour un reçu fiscal."
127-
128112
#. module: pos_donation
129113
#. odoo-python
130114
#: code:addons/pos_donation/models/donation.py:0
131115
#, python-format
132116
msgid "Various"
133117
msgstr "Divers"
118+
119+
#~ msgid "Product for donation in pos must belong to a company."
120+
#~ msgstr ""
121+
#~ "Un produit représentant une donation doit appartenir à une entreprise"

pos_donation/i18n/pos_donation.pot

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: Odoo Server 16.0\n"
88
"Report-Msgid-Bugs-To: \n"
9-
"POT-Creation-Date: 2025-07-13 07:26+0000\n"
10-
"PO-Revision-Date: 2025-07-13 07:26+0000\n"
119
"Last-Translator: \n"
1210
"Language-Team: \n"
1311
"MIME-Version: 1.0\n"
@@ -47,7 +45,13 @@ msgstr ""
4745

4846
#. module: pos_donation
4947
#: model:ir.model.fields.selection,name:pos_donation.selection__product_template__detailed_type__donation_in_pos
50-
msgid "Donation in POS"
48+
msgid "Donation in PoS"
49+
msgstr ""
50+
51+
#. module: pos_donation
52+
#: model_terms:product.template,description:pos_donation.product_product_donation_pos_product_template
53+
msgid ""
54+
"Donation item that can be sold in PoS and that is eligible for a tax receipt"
5155
msgstr ""
5256

5357
#. module: pos_donation
@@ -60,34 +64,28 @@ msgstr ""
6064
msgid "None"
6165
msgstr ""
6266

67+
#. module: pos_donation
68+
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__displayed_payment_mode
69+
msgid "Payment Mode"
70+
msgstr ""
71+
6372
#. module: pos_donation
6473
#: model:product.template,name:pos_donation.product_product_donation_pos_product_template
65-
msgid "POS Donation"
74+
msgid "PoS Donation"
6675
msgstr ""
6776

6877
#. module: pos_donation
6978
#. odoo-python
7079
#: code:addons/pos_donation/models/donation.py:0
71-
#: code:addons/pos_donation/models/donation.py:0
72-
#: code:addons/src/oca/pos/pos_donation/models/donation.py:0
80+
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__pos_order_id
7381
#: model_terms:ir.ui.view,arch_db:pos_donation.donation_form
7482
#, python-format
75-
msgid "POS Order"
76-
msgstr ""
77-
78-
#. module: pos_donation
79-
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__displayed_payment_mode
80-
msgid "Payment Mode"
81-
msgstr ""
82-
83-
#. module: pos_donation
84-
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__pos_order_id
8583
msgid "PoS Order"
8684
msgstr ""
8785

8886
#. module: pos_donation
89-
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__pos_payment_ids
90-
msgid "PoS payment methods"
87+
#: model:ir.model.fields,field_description:pos_donation.field_donation_donation__pos_payment_method_ids
88+
msgid "PoS Payment Methods"
9189
msgstr ""
9290

9391
#. module: pos_donation
@@ -106,24 +104,6 @@ msgstr ""
106104
msgid "Product Type"
107105
msgstr ""
108106

109-
#. module: pos_donation
110-
#. odoo-python
111-
#: code:addons/pos_donation/models/product_template.py:0
112-
#: code:addons/pos_donation/models/product_template.py:0
113-
#: code:addons/src/oca/pos/pos_donation/models/product_template.py:0
114-
#: model:ir.model.constraint,message:pos_donation.constraint_product_template_check_company_id_for_donation_in_pos
115-
#, python-format
116-
msgid ""
117-
"Product for donation in pos must belong to a company."
118-
msgstr ""
119-
120-
#. module: pos_donation
121-
#: model_terms:product.template,description:pos_donation.product_product_donation_pos_product_template
122-
msgid ""
123-
"This donation item that can be sold in POS and is eligible for a tax "
124-
"receipt."
125-
msgstr ""
126-
127107
#. module: pos_donation
128108
#. odoo-python
129109
#: code:addons/pos_donation/models/donation.py:0

pos_donation/models/donation.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,43 @@ class DonationDonation(models.Model):
1212
string="PoS Order",
1313
comodel_name="pos.order",
1414
)
15-
pos_payment_ids = fields.Many2many(
16-
string="PoS payment methods", comodel_name="pos.payment"
15+
pos_payment_method_ids = fields.Many2many(
16+
"pos.payment.method",
17+
string="PoS Payment Methods",
18+
compute="_compute_pos_payment_method_ids",
1719
)
1820
displayed_payment_mode = fields.Char(
19-
string="Payment Mode",
21+
# non-breaking space here to avoid warning (because this is done on
22+
# purpose): Two fields (displayed_payment_mode, payment_mode_id) of
23+
# donation.donation() have the same label: Payment Mode. [Modules:
24+
# pos_donation and donation]
25+
string="Payment Mode",
2026
compute="_compute_displayed_payment_mode",
2127
)
2228

23-
@api.depends("pos_payment_ids", "payment_mode_id")
29+
@api.depends("pos_order_id.payment_ids.payment_method_id")
30+
def _compute_pos_payment_method_ids(self):
31+
for rec in self:
32+
rec.pos_payment_method_ids = rec.pos_order_id.payment_ids.payment_method_id
33+
34+
@api.depends("pos_order_id.payment_ids.payment_method_id", "payment_mode_id")
2435
def _compute_displayed_payment_mode(self):
2536
for donation in self:
26-
if len(donation.pos_payment_ids) > 1:
27-
donation.displayed_payment_mode = _("Various")
28-
elif len(donation.pos_payment_ids) == 1:
29-
donation.displayed_payment_mode = (
30-
donation.pos_payment_ids.payment_method_id.name
31-
)
37+
if donation.pos_payment_method_ids:
38+
if len(donation.pos_payment_method_ids) > 1:
39+
donation.displayed_payment_mode = _("Various")
40+
else:
41+
donation.displayed_payment_mode = (
42+
donation.pos_payment_method_ids.name
43+
)
3244
else:
3345
donation.displayed_payment_mode = donation.payment_mode_id.name
3446

3547
def action_view_pos_order_id(self):
3648
return {
3749
"type": "ir.actions.act_window",
38-
"name": _("POS Order"),
50+
"name": _("PoS Order"),
3951
"res_model": "pos.order",
4052
"view_mode": "tree,form",
41-
"domain": [("id", "in", self.pos_order_id.ids)],
53+
"domain": [("id", "=", self.pos_order_id.id)],
4254
}
43-
44-
def validate(self):
45-
"""Keep payment_mode_id for donation_in_pos"""
46-
payment_modes = {}
47-
for donation in self:
48-
payment_modes[donation.id] = donation.payment_mode_id
49-
res = super().validate()
50-
for donation in self:
51-
if "donation_in_pos" in donation.line_ids.product_id.mapped(
52-
"detailed_type"
53-
):
54-
donation.payment_mode_id = payment_modes[donation.id]
55-
return res

pos_donation/models/donation_line.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class DonationLine(models.Model):
99
_inherit = "donation.line"
1010

1111
def _compute_in_kind(self):
12-
"""Donation in POS should be considered as donation in-kind.
12+
"""Donation in PoS should be considered as donation in-kind.
1313
These donation should not generate account move,
14-
because account move has already been generated by the POS.
14+
because account move has already been generated by the PoS.
1515
"""
1616
res = super()._compute_in_kind()
1717
for line in self:

0 commit comments

Comments
 (0)