From 22c606a71ef0681dfa731d3e442f3058c320b1f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Arturo=20Garci=CC=81a?= Date: Fri, 14 Aug 2026 17:07:58 -0400 Subject: [PATCH] =?UTF-8?q?Migrate=20package=20ownership=20to=20Fundaci?= =?UTF-8?q?=C3=B3n=20Un=20Pa=C3=ADs=20Mejor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/publish.yml | 4 ++-- CHANGELOG | 7 +++++++ COPYRIGHT | 1 + README.rst | 6 +++++- doc/conf.py | 15 +++++---------- doc/index.rst | 5 ++++- invoice.py | 26 +++++++++++--------------- locale/es.po | 8 ++++++-- locale/es_419.po | 10 +++++++--- message.xml | 3 +++ pyproject.toml | 8 ++++---- tests/test_module.py | 8 ++++++++ tryton.cfg | 2 +- 13 files changed, 64 insertions(+), 39 deletions(-) diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index 683b45d..21d2ea9 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -75,7 +75,7 @@ jobs: OWNER = 'tryton-do' PACKAGE_TYPE = 'pypi' - API_ROOT = 'https://gitea.joseagrc.com/api/v1' + API_ROOT = 'https://code.unpaismejor.org.do/api/v1' def normalize(name): return re.sub(r'[-_.]+', '-', name).lower() @@ -187,5 +187,5 @@ jobs: TWINE_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} run: | python -m twine upload \ - --repository-url https://gitea.joseagrc.com/api/packages/tryton-do/pypi \ + --repository-url https://code.unpaismejor.org.do/api/packages/tryton-do/pypi \ dist/* diff --git a/CHANGELOG b/CHANGELOG index e69de29..f5eb169 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -0,0 +1,7 @@ +Version 8.0.1 - 2026-08-14 +* Maintain the module under Fundación Un País Mejor. +* Publish it as unpaismejor_account_credit_note. +* Delegate full credit notes and refunds entirely to Tryton core. +* Restrict custom line and tax adjustments to partial credit notes. +* Reject a fixed partial amount applied to multiple source invoices. +* Update repository and package publication URLs. diff --git a/COPYRIGHT b/COPYRIGHT index fad965c..6924d90 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,4 +1,5 @@ Copyright (C) 2026 Solutema SRL +Copyright (C) 2026 Fundación Un País Mejor This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/README.rst b/README.rst index 2be01e9..1aaef5f 100644 --- a/README.rst +++ b/README.rst @@ -8,12 +8,16 @@ The module keeps the core credit workflow for full credit notes and only adjusts generated invoice lines when a partial credit is requested. Taxes are recomputed from the adjusted lines using Tryton's invoice logic. +The package is maintained by Fundación Un País Mejor. Full credit notes and +refunds are delegated unchanged to Tryton's ``account_invoice`` module. A fixed +partial amount may only be applied to one source invoice at a time. + Installing ********** Install the package and activate the module in the database:: - pip install trytond_account_credit_note + pip install unpaismejor_account_credit_note trytond-admin -d -u account_credit_note Publishing diff --git a/doc/conf.py b/doc/conf.py index 8513b72..23414e2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -8,8 +8,7 @@ trytond_url = 'https://docs.tryton.org/projects/server/en/{series}/' def get_info(): import configparser import os - import subprocess - import sys + import tomllib module_dir = os.path.dirname(os.path.dirname(__file__)) @@ -17,15 +16,11 @@ def get_info(): config.read_file(open(os.path.join(module_dir, 'tryton.cfg'))) info = dict(config.items('tryton')) - result = subprocess.run( - [sys.executable, 'setup.py', '--name'], - stdout=subprocess.PIPE, check=True, cwd=module_dir) - info['name'] = result.stdout.decode('utf-8').strip() + with open(os.path.join(module_dir, 'pyproject.toml'), 'rb') as stream: + project = tomllib.load(stream)['project'] + info['name'] = project['name'] - result = subprocess.run( - [sys.executable, 'setup.py', '--version'], - stdout=subprocess.PIPE, check=True, cwd=module_dir) - version = result.stdout.decode('utf-8').strip() + version = info['version'] if 'dev' in version: info['series'] = 'latest' else: diff --git a/doc/index.rst b/doc/index.rst index 2be01e9..40dc61a 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -8,12 +8,15 @@ The module keeps the core credit workflow for full credit notes and only adjusts generated invoice lines when a partial credit is requested. Taxes are recomputed from the adjusted lines using Tryton's invoice logic. +The package is maintained by Fundación Un País Mejor. Full credit notes and +refunds are delegated unchanged to Tryton core. + Installing ********** Install the package and activate the module in the database:: - pip install trytond_account_credit_note + pip install unpaismejor_account_credit_note trytond-admin -d -u account_credit_note Publishing diff --git a/invoice.py b/invoice.py index 1e8fd9d..592c40e 100644 --- a/invoice.py +++ b/invoice.py @@ -313,11 +313,21 @@ class Invoice(metaclass=PoolMeta): workflow cancels the original invoice, which is not correct for a partial credit note. """ + invoices = list(invoices) credit_mode = values.pop('credit_mode', None) or 'full' credit_percent = values.pop('credit_percent', None) credit_amount = values.pop('credit_amount', None) credit_amount_basis = values.pop('credit_amount_basis', None) or 'total' + # Preserve the official account_invoice behavior without custom line, + # tax, posting or cancellation logic for a full credit note. + if credit_mode == 'full': + return super().credit(invoices, refund=refund, **values) + + if credit_mode == 'amount' and len(invoices) != 1: + raise UserError(gettext( + 'account_credit_note.msg_amount_multiple_invoices')) + factors = [ cls._credit_partial_compute_factor( origin, credit_mode, credit_percent, credit_amount, @@ -325,8 +335,7 @@ class Invoice(metaclass=PoolMeta): for origin in invoices ] - is_partial = any(factor != _ONE for factor in factors) - if refund and is_partial: + if refund: raise UserError(gettext( 'account_credit_note.msg_partial_refund_not_allowed')) @@ -351,19 +360,6 @@ class Invoice(metaclass=PoolMeta): cls.save(new_invoices) - if refund: - # Same behavior as account_invoice.Invoice.credit(refund=True), but - # executed after possible edits to the generated credit note. - cls.post(new_invoices) - for invoice, new_invoice in zip(invoices, new_invoices): - if invoice.state != 'posted': - raise UserError(gettext( - 'account_invoice.msg_invoice_credit_refund_not_posted', - invoice=invoice.rec_name)) - invoice.cancel_move = new_invoice.move - cls.save(invoices) - cls.cancel(invoices) - return new_invoices diff --git a/locale/es.po b/locale/es.po index 50112e1..4d7b381 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: account_credit_note 8.0\n" -"PO-Revision-Date: 2026-07-23 00:00-0400\n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2026-08-14 00:00-0400\n" +"Last-Translator: Fundación Un País Mejor\n" "Language-Team: Spanish\n" "Language: es\n" "MIME-Version: 1.0\n" @@ -58,6 +58,10 @@ msgctxt "model:ir.message,text:msg_partial_refund_not_allowed" msgid "Partial credit notes can not be posted as refunds automatically." msgstr "Las notas de crédito parciales no pueden contabilizarse automáticamente como devoluciones." +msgctxt "model:ir.message,text:msg_amount_multiple_invoices" +msgid "A fixed credit amount can only be applied to one source invoice at a time." +msgstr "Un importe fijo de crédito solo puede aplicarse a una factura origen a la vez." + msgctxt "model:ir.ui.view,name:credit_start_view_form" msgid "credit_start_form" msgstr "credit_start_form" diff --git a/locale/es_419.po b/locale/es_419.po index 0c4bb99..cc1288c 100644 --- a/locale/es_419.po +++ b/locale/es_419.po @@ -1,9 +1,9 @@ # msgid "" msgstr "" -"Project-Id-Version: account_credit_note 7.0\n" -"PO-Revision-Date: 2026-07-15 00:00-0400\n" -"Last-Translator: Automatically generated\n" +"Project-Id-Version: account_credit_note 8.0\n" +"PO-Revision-Date: 2026-08-14 00:00-0400\n" +"Last-Translator: Fundación Un País Mejor\n" "Language-Team: Spanish (Latin America)\n" "Language: es_419\n" "MIME-Version: 1.0\n" @@ -58,6 +58,10 @@ msgctxt "model:ir.message,text:msg_partial_refund_not_allowed" msgid "Partial credit notes can not be posted as refunds automatically." msgstr "Las notas de crédito parciales no se pueden contabilizar automáticamente como reembolsos." +msgctxt "model:ir.message,text:msg_amount_multiple_invoices" +msgid "A fixed credit amount can only be applied to one source invoice at a time." +msgstr "Un monto fijo de crédito solo puede aplicarse a una factura origen a la vez." + msgctxt "model:ir.ui.view,name:credit_start_view_form" msgid "credit_start_form" msgstr "credit_start_form" diff --git a/message.xml b/message.xml index 4bc3d21..c1bb805 100644 --- a/message.xml +++ b/message.xml @@ -25,5 +25,8 @@ Partial credit notes can not be posted as refunds automatically. + + A fixed credit amount can only be applied to one source invoice at a time. + diff --git a/pyproject.toml b/pyproject.toml index f3eb8b6..fa1f9cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,11 +3,11 @@ requires = ['hatchling >= 1', 'hatch-tryton'] build-backend = 'hatchling.build' [project] -name = 'trytond_account_credit_note' +name = 'unpaismejor_account_credit_note' dynamic = ['version', 'dependencies', 'optional-dependencies', 'authors', 'readme'] requires-python = '>=3.10' maintainers = [ - {name = "Solutema"}, + {name = "Fundación Un País Mejor"}, ] description = "Partial credit notes for Tryton invoices" license = 'GPL-3.0-or-later' @@ -26,8 +26,8 @@ classifiers = [ account_credit_note = 'trytond.modules.account_credit_note' [project.urls] -homepage = "https://www.tryton.org/" -repository = "https://gitea.joseagrc.com/tryton-do/account_credit_note" +homepage = "https://www.unpaismejor.org.do" +repository = "https://code.unpaismejor.org.do/tryton-do/account_credit_note" [tool.hatch.build] include = [ diff --git a/tests/test_module.py b/tests/test_module.py index 449a7f3..0b3a06e 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -50,5 +50,13 @@ class AccountCreditNoteLogicTestCase(unittest.TestCase): Invoice._credit_partial_compute_factor( MockInvoice(), 'amount', None, Decimal('119'), 'total') + def test_fixed_amount_rejects_multiple_invoices(self): + with self.assertRaises(UserError): + Invoice.credit( + [MockInvoice(), MockInvoice()], + credit_mode='amount', + credit_amount=Decimal('10'), + credit_amount_basis='total') + del ModuleTestCase diff --git a/tryton.cfg b/tryton.cfg index b958783..9fa0651 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=8.0.0 +version=8.0.1 depends: account_invoice xml: