From 28be2b7509a4dba2712e3c07e8f723499506e2d5 Mon Sep 17 00:00:00 2001 From: Bonnerue Date: Tue, 3 Jun 2025 17:18:06 +0200 Subject: [PATCH 1/9] [MIG] donation_base: Migration to 18.0 --- donation_base/__manifest__.py | 2 +- donation_base/data/donation_mail_template.xml | 9 ++-- .../migrations/16.0.2.0.0/pre-migration.py | 24 --------- donation_base/models/product.py | 50 ++++++++++--------- donation_base/views/donation_tax_receipt.xml | 14 ++---- donation_base/views/product.xml | 8 +-- donation_base/views/res_partner.xml | 11 ++-- 7 files changed, 46 insertions(+), 72 deletions(-) delete mode 100644 donation_base/migrations/16.0.2.0.0/pre-migration.py diff --git a/donation_base/__manifest__.py b/donation_base/__manifest__.py index e713c7042..2c2557244 100644 --- a/donation_base/__manifest__.py +++ b/donation_base/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Donation Base", - "version": "16.0.2.0.0", + "version": "18.0.1.0.0", "category": "Accounting", "license": "AGPL-3", "summary": "Base module for donations", diff --git a/donation_base/data/donation_mail_template.xml b/donation_base/data/donation_mail_template.xml index 7f459c073..a34877942 100644 --- a/donation_base/data/donation_mail_template.xml +++ b/donation_base/data/donation_mail_template.xml @@ -14,10 +14,13 @@ {{object.partner_id.id}} - {{object.company_id.name.replace(' ', '_')}}-Tax_Receipt_{{(object.number or '').replace('/','_')}} + name="report_template_ids" + eval="[(4, ref('report_donation_tax_receipt'))]" + /> + + + {{object.partner_id.lang}}
diff --git a/donation_base/migrations/16.0.2.0.0/pre-migration.py b/donation_base/migrations/16.0.2.0.0/pre-migration.py deleted file mode 100644 index c07da1568..000000000 --- a/donation_base/migrations/16.0.2.0.0/pre-migration.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2023 Akretion France (http://www.akretion.com/) -# @author: Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - - -def migrate(cr, version): - if not version: - return - - cr.execute( - """UPDATE product_template - SET detailed_type='donation_in_kind_service' - WHERE donation IS true AND in_kind_donation IS true AND type = 'service'""" - ) - cr.execute( - """UPDATE product_template - SET detailed_type='donation_in_kind_consu' - WHERE donation IS true AND in_kind_donation IS true AND type = 'consu'""" - ) - cr.execute( - """UPDATE product_template - SET detailed_type='donation' - WHERE donation IS true AND in_kind_donation IS NOT true""" - ) diff --git a/donation_base/models/product.py b/donation_base/models/product.py index 6bce84c23..e41e2935f 100644 --- a/donation_base/models/product.py +++ b/donation_base/models/product.py @@ -10,18 +10,28 @@ class ProductTemplate(models.Model): _inherit = "product.template" - detailed_type = fields.Selection( + service_tracking = fields.Selection( selection_add=[ ("donation", "Donation"), - ("donation_in_kind_consu", "In-Kind Donation Consummable"), ("donation_in_kind_service", "In-Kind Donation Service"), ], ondelete={ - "donation": "set service", - "donation_in_kind_consu": "set consu", - "donation_in_kind_service": "set service", + "donation": "set default", + "donation_in_kind_service": "set default", }, ) + # service_tracking = fields.Selection( + # selection_add=[ + # ("donation", "Donation"), + # ("donation_in_kind_consu", "In-Kind Donation Consummable"), + # ("donation_in_kind_service", "In-Kind Donation Service"), + # ], + # ondelete={ + # "donation": "set service", + # "donation_in_kind_consu": "set consu", + # "donation_in_kind_service": "set service", + # }, + # ) tax_receipt_ok = fields.Boolean( string="Is Eligible for a Tax Receipt", tracking=True, @@ -32,34 +42,23 @@ class ProductTemplate(models.Model): help="Specify if the product is eligible for a tax receipt", ) - @api.depends("detailed_type") + @api.depends("service_tracking") def _compute_tax_receipt_ok(self): for product in self: - if product.detailed_type and not product.detailed_type.startswith( + if product.service_tracking and not product.service_tracking.startswith( "donation" ): product.tax_receipt_ok = False - def _detailed_type_mapping(self): - res = super()._detailed_type_mapping() - res.update( - { - "donation": "service", - "donation_in_kind_consu": "consu", - "donation_in_kind_service": "service", - } - ) - return res - - @api.onchange("detailed_type") + @api.onchange("service_tracking") def _donation_change(self): for product in self: - if product.detailed_type == "donation": + if product.service_tracking == "donation": product.taxes_id = False product.supplier_taxes_id = False product.purchase_ok = False - @api.constrains("detailed_type", "taxes_id") + @api.constrains("service_tracking", "taxes_id") def donation_check(self): for product in self: # The check below is to make sure that we don't forget to remove @@ -67,7 +66,7 @@ def donation_check(self): # for users of donation_sale. If there are countries that have # sale tax on donations (!), please tell us and we can remove this # constraint - if product.detailed_type == "donation" and product.taxes_id: + if product.service_tracking == "donation" and product.taxes_id: raise ValidationError( _( "There shouldn't have any Customer Taxes on the " @@ -76,14 +75,17 @@ def donation_check(self): % product.display_name ) + def _service_tracking_blacklist(self): + return super()._service_tracking_blacklist() + ["donation"] + class ProductProduct(models.Model): _inherit = "product.product" - @api.onchange("detailed_type") + @api.onchange("service_tracking") def _donation_change(self): for product in self: - if product.detailed_type == "donation": + if product.service_tracking == "donation": product.taxes_id = False product.supplier_taxes_id = False product.purchase_ok = False diff --git a/donation_base/views/donation_tax_receipt.xml b/donation_base/views/donation_tax_receipt.xml index 30fcc8399..122ac4a96 100644 --- a/donation_base/views/donation_tax_receipt.xml +++ b/donation_base/views/donation_tax_receipt.xml @@ -43,19 +43,15 @@ -
- - - -
+
- donation.tax.receipt.tree + donation.tax.receipt.list donation.tax.receipt - + @@ -75,7 +71,7 @@ groups="base.group_multi_company" optional="show" /> - + @@ -153,6 +149,6 @@ Donation Tax Receipts donation.tax.receipt - tree,form,graph,pivot + list,form,graph,pivot diff --git a/donation_base/views/product.xml b/donation_base/views/product.xml index d2c0c3cde..c0c2a1c53 100644 --- a/donation_base/views/product.xml +++ b/donation_base/views/product.xml @@ -11,11 +11,11 @@ product.template - + @@ -32,11 +32,11 @@ product.template - + diff --git a/donation_base/views/res_partner.xml b/donation_base/views/res_partner.xml index fead18309..7aa984608 100644 --- a/donation_base/views/res_partner.xml +++ b/donation_base/views/res_partner.xml @@ -9,7 +9,7 @@ Donation Tax Receipts donation.tax.receipt - tree,form,graph,pivot + list,form,graph,pivot {'search_default_partner_id': active_id} @@ -21,10 +21,7 @@ expr="//group[@name='fiscal_information']/field[@name='property_account_position_id']" position="after" > - + @@ -33,7 +30,7 @@ class="oe_stat_button" type="action" name="%(donation_base.partner_tax_receipt_action)d" - attrs="{'invisible': [('parent_id', '!=', False)]}" + invisible="parent_id != False" icon="fa-file-text" groups="account.group_account_invoice,account.group_account_readonly" > @@ -59,7 +56,7 @@ Donors res.partner - kanban,tree,form + kanban,list,form {'search_default_donor': 1, 'res_partner_search_mode': 'donor', 'default_is_company': False, 'default_donor_rank': 1} From 69bf1d2d9ab8c54a11682e8e1cc6a9d5b48e2fa5 Mon Sep 17 00:00:00 2001 From: Florian du Garage Num Date: Thu, 10 Jul 2025 23:31:35 +0200 Subject: [PATCH 2/9] remove nested loop in tax reports like in PR https://github.com/OCA/donation/pull/135 --- donation_base/report/report_donationtax.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/donation_base/report/report_donationtax.xml b/donation_base/report/report_donationtax.xml index 95f5464e4..4bef04704 100644 --- a/donation_base/report/report_donationtax.xml +++ b/donation_base/report/report_donationtax.xml @@ -9,7 +9,6 @@