From 6965b755e02d064bebff41b88cd51f16de8ef308 Mon Sep 17 00:00:00 2001 From: Francisco Ivan Anton Prieto Date: Fri, 2 Apr 2021 13:49:16 +0200 Subject: [PATCH] [MIG] contract: Migration to 14.0 --- contract/README.rst | 18 ++++------ contract/__manifest__.py | 2 +- contract/data/contract_cron.xml | 2 +- contract/data/contract_renew_cron.xml | 2 +- contract/data/mail_message_subtype.xml | 2 +- contract/data/mail_template.xml | 2 +- .../13.0.1.0.0/noupdate_changes.xml | 28 ---------------- .../migrations/13.0.1.0.0/post-migration.py | 33 ------------------- contract/models/abstract_contract_line.py | 4 +-- contract/models/contract.py | 20 +++++------ contract/models/contract_line.py | 5 ++- contract/models/res_partner.py | 8 ++--- contract/readme/CONTRIBUTORS.rst | 1 + contract/readme/USAGE.rst | 7 +--- contract/report/contract_views.xml | 19 ++++++----- contract/report/report_contract.xml | 3 +- contract/security/contract_security.xml | 2 +- contract/security/ir.model.access.csv | 3 ++ contract/static/description/index.html | 17 ++++------ contract/tests/test_contract.py | 7 ++-- contract/tests/test_portal.py | 2 +- .../contract_manually_create_invoice.xml | 2 +- 22 files changed, 62 insertions(+), 127 deletions(-) delete mode 100644 contract/migrations/13.0.1.0.0/noupdate_changes.xml delete mode 100644 contract/migrations/13.0.1.0.0/post-migration.py diff --git a/contract/README.rst b/contract/README.rst index 6cd3860e0..31a03b4e2 100644 --- a/contract/README.rst +++ b/contract/README.rst @@ -14,13 +14,13 @@ Recurring - Contracts Management :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github - :target: https://github.com/OCA/contract/tree/13.0/contract + :target: https://github.com/OCA/contract/tree/14.0/contract :alt: OCA/contract .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/contract-13-0/contract-13-0-contract + :target: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/110/13.0 + :target: https://runbot.odoo-community.org/runbot/110/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -73,12 +73,7 @@ Usage #. Contract templates can be created from the Configuration -> Contracts -> Contract Templates menu. They allow to define default journal, price list and lines when creating a contract. To use it, just select the template on the contract and fields will be filled automatically. - -* Contracts appear in portal to following users in every contract: - -.. image:: https://raw.githubusercontent.com/OCA/contract/13.0/contract/static/src/screenshots/portal-my.png -.. image:: https://raw.githubusercontent.com/OCA/contract/13.0/contract/static/src/screenshots/portal-list.png -.. image:: https://raw.githubusercontent.com/OCA/contract/13.0/contract/static/src/screenshots/portal-detail.png +#. Contracts are displayed into followers' user portal. Known issues / Roadmap ====================== @@ -92,7 +87,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -123,6 +118,7 @@ Contributors * Vicent Cubells * Rafael Blasco * Víctor Martínez +* Iván Antón Maintainers ~~~~~~~~~~~ @@ -137,6 +133,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/contract `_ project on GitHub. +This module is part of the `OCA/contract `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 5cc8462b3..df2f2781f 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -11,7 +11,7 @@ { "name": "Recurring - Contracts Management", - "version": "13.0.2.3.7", + "version": "14.0.1.0.0", "category": "Contract Management", "license": "AGPL-3", "author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/contract/data/contract_cron.xml b/contract/data/contract_cron.xml index 5fcb4b961..379e7a0a2 100644 --- a/contract/data/contract_cron.xml +++ b/contract/data/contract_cron.xml @@ -1,4 +1,4 @@ - + Generate Recurring Invoices from Contracts diff --git a/contract/data/contract_renew_cron.xml b/contract/data/contract_renew_cron.xml index 2fa24b1d0..1a5b57025 100644 --- a/contract/data/contract_renew_cron.xml +++ b/contract/data/contract_renew_cron.xml @@ -1,4 +1,4 @@ - + Renew Contract lines diff --git a/contract/data/mail_message_subtype.xml b/contract/data/mail_message_subtype.xml index e3d73cbaa..eeea19107 100644 --- a/contract/data/mail_message_subtype.xml +++ b/contract/data/mail_message_subtype.xml @@ -1,4 +1,4 @@ - + Invoice created diff --git a/contract/data/mail_template.xml b/contract/data/mail_template.xml index c6356ede6..5c1ef206c 100644 --- a/contract/data/mail_template.xml +++ b/contract/data/mail_template.xml @@ -1,4 +1,4 @@ - + Email Contract Template diff --git a/contract/migrations/13.0.1.0.0/noupdate_changes.xml b/contract/migrations/13.0.1.0.0/noupdate_changes.xml deleted file mode 100644 index 468506ed9..000000000 --- a/contract/migrations/13.0.1.0.0/noupdate_changes.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - ['|',('company_id','=',False),('company_id','in',company_ids)] - - - ['|',('company_id','=',False),('company_id','in',company_ids)] - - - ['|',('company_id','=',False),('company_id','in',company_ids)] - - - ['|',('company_id','=',False),('company_id','in',company_ids)] - - - ['|',('company_id','=',False),('company_id','in',company_ids)] - - diff --git a/contract/migrations/13.0.1.0.0/post-migration.py b/contract/migrations/13.0.1.0.0/post-migration.py deleted file mode 100644 index 11a817780..000000000 --- a/contract/migrations/13.0.1.0.0/post-migration.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2020-2021 Tecnativa - Pedro M. Baeza -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade # pylint: disable=W7936 - - -@openupgrade.migrate() -def migrate(env, version): - openupgrade.logged_query( - env.cr, - """ - UPDATE account_move am - SET old_contract_id = ai.old_contract_id - FROM account_invoice ai - WHERE ai.id = am.old_invoice_id - AND ai.old_contract_id IS NOT NULL""", - ) - openupgrade.logged_query( - env.cr, - """ - UPDATE account_move_line aml - SET contract_line_id = ail.contract_line_id - FROM account_invoice_line ail - WHERE ail.id = aml.old_invoice_line_id - AND ail.contract_line_id IS NOT NULL""", - ) - openupgrade.load_data( - env.cr, "contract", "migrations/13.0.1.0.0/noupdate_changes.xml" - ) - - # Don't alter line recurrence v12 behavior - contracts = env["contract.contract"].search([]) - contracts.write({"line_recurrence": True}) diff --git a/contract/models/abstract_contract_line.py b/contract/models/abstract_contract_line.py index b02a56de9..6ee8e229e 100644 --- a/contract/models/abstract_contract_line.py +++ b/contract/models/abstract_contract_line.py @@ -186,8 +186,8 @@ class ContractAbstractContractLine(models.AbstractModel): if line.automatic_price: pricelist = ( line.contract_id.pricelist_id - or line.contract_id.partner_id.with_context( - force_company=line.contract_id.company_id.id, + or line.contract_id.partner_id.with_company( + line.contract_id.company_id ).property_product_pricelist ) product = line.product_id.with_context( diff --git a/contract/models/contract.py b/contract/models/contract.py index 4f62a7dd1..e75a705f7 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -239,8 +239,8 @@ class ContractContract(models.Model): # Use pricelist currency currency = ( self.pricelist_id.currency_id - or self.partner_id.with_context( - force_company=self.company_id.id, + or self.partner_id.with_company( + self.company_id ).property_product_pricelist.currency_id ) return currency or self.journal_id.currency_id or self.company_id.currency_id @@ -360,7 +360,7 @@ class ContractContract(models.Model): partner = ( self.partner_id if not self.company_id - else self.partner_id.with_context(force_company=self.company_id.id) + else self.partner_id.with_company(self.company_id) ) self.pricelist_id = partner.property_product_pricelist.id self.fiscal_position_id = partner.env[ @@ -423,9 +423,9 @@ class ContractContract(models.Model): if self.contract_type == "purchase": invoice_type = "in_invoice" move_form = Form( - self.env["account.move"].with_context( - force_company=self.company_id.id, default_type=invoice_type - ) + self.env["account.move"] + .with_company(self.company_id) + .with_context(default_move_type=invoice_type) ) move_form.partner_id = self.invoice_partner_id if self.payment_term_id: @@ -491,11 +491,11 @@ class ContractContract(models.Model): """ self.ensure_one() - def can_be_invoiced(l): + def can_be_invoiced(contract_line): return ( - not l.is_canceled - and l.recurring_next_date - and l.recurring_next_date <= date_ref + not contract_line.is_canceled + and contract_line.recurring_next_date + and contract_line.recurring_next_date <= date_ref ) lines2invoice = previous = self.env["contract.line"] diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py index 8a785673d..29722094e 100644 --- a/contract/models/contract_line.py +++ b/contract/models/contract_line.py @@ -382,7 +382,10 @@ class ContractLine(models.Model): @api.constrains("predecessor_contract_line_id", "date_start") def _check_overlap_predecessor(self): for rec in self: - if rec.predecessor_contract_line_id: + if ( + rec.predecessor_contract_line_id + and rec.predecessor_contract_line_id.date_end + ): if rec.date_start <= rec.predecessor_contract_line_id.date_end: raise ValidationError( _("Contract line and its predecessor overlapped") diff --git a/contract/models/res_partner.py b/contract/models/res_partner.py index f494ce578..55dcfba5c 100644 --- a/contract/models/res_partner.py +++ b/contract/models/res_partner.py @@ -71,10 +71,10 @@ class ResPartner(models.Model): def _get_act_window_contract_xml(self, contract_type): if contract_type == "purchase": - return self.env["ir.actions.act_window"].for_xml_id( - "contract", "action_supplier_contract" + return self.env["ir.actions.act_window"]._for_xml_id( + "contract.action_supplier_contract" ) else: - return self.env["ir.actions.act_window"].for_xml_id( - "contract", "action_customer_contract" + return self.env["ir.actions.act_window"]._for_xml_id( + "contract.action_customer_contract" ) diff --git a/contract/readme/CONTRIBUTORS.rst b/contract/readme/CONTRIBUTORS.rst index 6fd5286a2..dda95e89e 100644 --- a/contract/readme/CONTRIBUTORS.rst +++ b/contract/readme/CONTRIBUTORS.rst @@ -13,3 +13,4 @@ * Vicent Cubells * Rafael Blasco * Víctor Martínez +* Iván Antón diff --git a/contract/readme/USAGE.rst b/contract/readme/USAGE.rst index 7257cf153..0ce99cd9b 100644 --- a/contract/readme/USAGE.rst +++ b/contract/readme/USAGE.rst @@ -23,9 +23,4 @@ #. Contract templates can be created from the Configuration -> Contracts -> Contract Templates menu. They allow to define default journal, price list and lines when creating a contract. To use it, just select the template on the contract and fields will be filled automatically. - -* Contracts appear in portal to following users in every contract: - -.. image:: ../static/src/screenshots/portal-my.png -.. image:: ../static/src/screenshots/portal-list.png -.. image:: ../static/src/screenshots/portal-detail.png +#. Contracts are displayed into followers' user portal. diff --git a/contract/report/contract_views.xml b/contract/report/contract_views.xml index 1dcabeeb4..0cfef5eac 100644 --- a/contract/report/contract_views.xml +++ b/contract/report/contract_views.xml @@ -1,11 +1,14 @@ - + + + Contract + contract.contract + qweb-pdf + contract.report_contract_document + contract.report_contract + + report + + diff --git a/contract/report/report_contract.xml b/contract/report/report_contract.xml index 891113b26..2954ce5c8 100644 --- a/contract/report/report_contract.xml +++ b/contract/report/report_contract.xml @@ -1,4 +1,4 @@ - +