From c0ce3623341eae978a2bbbb1ec6fff4356b96284 Mon Sep 17 00:00:00 2001 From: Simone Rubino Date: Thu, 30 Mar 2023 10:41:38 +0200 Subject: [PATCH] [IMP] account_receipt_sale: Move Partner and Fiscal Position to base account_receipt_sale (LGPL-3) depends on account_receipt_base (AGPL-3) --- account_receipt_sale/__manifest__.py | 8 ++-- account_receipt_sale/models/__init__.py | 2 - .../models/account_fiscal_position.py | 29 ------------- account_receipt_sale/models/partner.py | 21 --------- account_receipt_sale/readme/CONFIGURE.rst | 3 +- account_receipt_sale/readme/CONTRIBUTORS.rst | 3 ++ account_receipt_sale/readme/DESCRIPTION.rst | 2 +- account_receipt_sale/tests/test_receipts.py | 43 +------------------ .../views/account_fiscal_position_views.xml | 14 ------ account_receipt_sale/views/partner_views.xml | 14 ------ 10 files changed, 12 insertions(+), 127 deletions(-) delete mode 100644 account_receipt_sale/models/account_fiscal_position.py delete mode 100644 account_receipt_sale/models/partner.py delete mode 100644 account_receipt_sale/views/account_fiscal_position_views.xml delete mode 100644 account_receipt_sale/views/partner_views.xml diff --git a/account_receipt_sale/__manifest__.py b/account_receipt_sale/__manifest__.py index f4604a908dda..98ff6a2a74e9 100644 --- a/account_receipt_sale/__manifest__.py +++ b/account_receipt_sale/__manifest__.py @@ -2,7 +2,8 @@ # Copyright 2018-2019 Simone Rubino # Copyright 2019 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo) # Copyright 2020 Giovanni Serra - GSLab.it -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +# Copyright 2023 Simone Rubino - TAKOBI +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Receipts from sales", "summary": "Generate receipts from sale orders", @@ -12,17 +13,16 @@ "website": "https://github.com/OCA/account-invoicing", "author": "TAKOBI, Agile Business Group, Odoo Community Association (OCA)", "maintainers": ["eLBati"], - "license": "LGPL-3", + "license": "AGPL-3", "application": False, "installable": True, "preloadable": True, "depends": [ + "account_receipt_base", "account_receipt_journal", "sale", ], "data": [ - "views/partner_views.xml", - "views/account_fiscal_position_views.xml", "views/sale_views.xml", ], "pre_init_hook": "rename_old_italian_module", diff --git a/account_receipt_sale/models/__init__.py b/account_receipt_sale/models/__init__.py index deac2d7bd494..8a0dc04e1fd0 100644 --- a/account_receipt_sale/models/__init__.py +++ b/account_receipt_sale/models/__init__.py @@ -1,3 +1 @@ -from . import account_fiscal_position -from . import partner from . import sale diff --git a/account_receipt_sale/models/account_fiscal_position.py b/account_receipt_sale/models/account_fiscal_position.py deleted file mode 100644 index 4ad6c31a3887..000000000000 --- a/account_receipt_sale/models/account_fiscal_position.py +++ /dev/null @@ -1,29 +0,0 @@ -from odoo import api, fields, models - - -class Position(models.Model): - _inherit = "account.fiscal.position" - receipts = fields.Boolean(string="Receipts") - - @api.model - def get_receipts_fiscal_pos(self, company_id=None): - if not company_id: - company_id = self.env.user.company_id - receipt_fiscal_pos = self.search( - [ - ("company_id", "=", company_id.id), - ("receipts", "=", True), - ], - limit=1, - ) - if not receipt_fiscal_pos: - # Fall back to fiscal positions without company - receipt_fiscal_pos = self.search( - [ - ("company_id", "=", False), - ("receipts", "=", True), - ], - limit=1, - ) - - return receipt_fiscal_pos diff --git a/account_receipt_sale/models/partner.py b/account_receipt_sale/models/partner.py deleted file mode 100644 index cb1d13e05c35..000000000000 --- a/account_receipt_sale/models/partner.py +++ /dev/null @@ -1,21 +0,0 @@ -from odoo import api, fields, models - - -class Partner(models.Model): - _inherit = "res.partner" - use_receipts = fields.Boolean(string="Use Receipts") - - @api.onchange("use_receipts") - def onchange_use_receipts(self): - if self.use_receipts: - # Partner is receipts, assign a receipts - # fiscal position only if there is none - if not self.property_account_position_id: - company = self.company_id or self.env.company - self.property_account_position_id = self.env[ - "account.fiscal.position" - ].get_receipts_fiscal_pos(company) - else: - # Unset the fiscal position only if it was receipts - if self.property_account_position_id.receipts: - self.property_account_position_id = False diff --git a/account_receipt_sale/readme/CONFIGURE.rst b/account_receipt_sale/readme/CONFIGURE.rst index f057ebadc4ad..8ae050e1e021 100644 --- a/account_receipt_sale/readme/CONFIGURE.rst +++ b/account_receipt_sale/readme/CONFIGURE.rst @@ -1 +1,2 @@ -If needed, create "receipts" fiscal positions and partners. + - Add your users to "Sale Receipt" group + - Go to Invoicing > Customers > Receipts diff --git a/account_receipt_sale/readme/CONTRIBUTORS.rst b/account_receipt_sale/readme/CONTRIBUTORS.rst index 9130098133e4..c22d3936f248 100644 --- a/account_receipt_sale/readme/CONTRIBUTORS.rst +++ b/account_receipt_sale/readme/CONTRIBUTORS.rst @@ -2,3 +2,6 @@ * Simone Rubino * Sergio Zanchetta * Giovanni Serra +* `TAKOBI `_: + + * Simone Rubino diff --git a/account_receipt_sale/readme/DESCRIPTION.rst b/account_receipt_sale/readme/DESCRIPTION.rst index 447e6d25ab0b..27f58eb62e13 100644 --- a/account_receipt_sale/readme/DESCRIPTION.rst +++ b/account_receipt_sale/readme/DESCRIPTION.rst @@ -1 +1 @@ -Based on `account_receipt_journal`, this module allows to create receipts from sale orders, configuring "receipts" fiscal positions and partners. +Based on `account_receipt_journal`, this module allows to create receipts from sale orders. diff --git a/account_receipt_sale/tests/test_receipts.py b/account_receipt_sale/tests/test_receipts.py index 713e837a789d..c1a57d658753 100644 --- a/account_receipt_sale/tests/test_receipts.py +++ b/account_receipt_sale/tests/test_receipts.py @@ -1,5 +1,7 @@ # Copyright 2018 Simone Rubino # Copyright 2022 Lorenzo Battistini +# Copyright 2023 Simone Rubino - TAKOBI +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests import tagged @@ -27,13 +29,6 @@ def setUp(self): "company_id": self.env.user.company_id.id, } ) - self.receipts_partner = partner_model.create( - { - "name": "Receipts partner", - "use_receipts": True, - "property_account_position_id": self.receipts_fiscal_position.id, - } - ) self.no_receipts_partner = partner_model.create( { "name": "No receipts partner", @@ -42,40 +37,6 @@ def setUp(self): } ) - def test_get_receipts_fiscal_pos(self): - """Test that get_receipts_fiscal_pos gets a receipts - fiscal position""" - receipts_fiscal_pos = self.fiscal_pos_model.get_receipts_fiscal_pos() - self.assertTrue(receipts_fiscal_pos.receipts) - - def test_receipts_partner_onchange(self): - """Test onchange in partner.""" - # If the partner uses receipts, - # the fiscal position must have the flag receipts - self.receipts_partner.onchange_use_receipts() - self.assertTrue(self.receipts_partner.property_account_position_id.receipts) - - # If the partner does not use receipts - # and it already has a fiscal position that is - # receipts, it must be removed - self.no_receipts_partner.write( - {"property_account_position_id": self.receipts_fiscal_position.id} - ) - self.no_receipts_partner.onchange_use_receipts() - self.assertFalse(self.no_receipts_partner.property_account_position_id) - - # If the partner does not use receipts - # and it already has a fiscal position that is - # not receipts, it must not be removed - self.no_receipts_partner.write( - {"property_account_position_id": self.no_receipts_fiscal_position.id} - ) - self.no_receipts_partner.onchange_use_receipts() - self.assertEqual( - self.no_receipts_partner.property_account_position_id, - self.no_receipts_fiscal_position, - ) - def test_order_creation(self): order_no_receipts = self.sale_model.create( { diff --git a/account_receipt_sale/views/account_fiscal_position_views.xml b/account_receipt_sale/views/account_fiscal_position_views.xml deleted file mode 100644 index c918464a7e50..000000000000 --- a/account_receipt_sale/views/account_fiscal_position_views.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - account.fiscal.position.form.receipts - account.fiscal.position - form - - - - - - - - diff --git a/account_receipt_sale/views/partner_views.xml b/account_receipt_sale/views/partner_views.xml deleted file mode 100644 index 8e9d67b3ffeb..000000000000 --- a/account_receipt_sale/views/partner_views.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - res.partner.form.receipts - res.partner - - - - - - - - -