From da393c937d736d9cee3ff848a10216c6dfac9b0a Mon Sep 17 00:00:00 2001
From: Jean-Charles Drubay
Date: Thu, 28 Oct 2021 18:24:51 +0700
Subject: [PATCH] [MIG] contract: Migration to 15.0
Most changes are related to the switch from jinja to qweb in mail templates.
Also included:
- convert deprecated onchange that returns a domain and other deprecation warnings
(see below)
- Add migration scripts from version 14.0 (force the update of the mail templates)
- Fix warnings from pre-commit checks
Fixes depreciation warnings:
- onchange method ContractAbstractContractLine._onchange_product_id returned
a domain, this is deprecated
- SavepointCase is deprecated:
https://github.com/odoo/odoo/blob/15.0/odoo/tests/common.py#L742
- assertDictContainsSubset: According to:
https://stackoverflow.com/questions/20050913/python-unittests-assertdictcontainssubset-recommended-alternative
---
contract/README.rst | 16 +-
contract/__manifest__.py | 10 +-
contract/data/mail_template.xml | 150 ++++++-----
contract/i18n/contract.pot | 236 +++++++++---------
contract/i18n/hr_HR.po | 2 +-
contract/i18n/it.po | 2 +-
contract/i18n/tr_TR.po | 2 +-
.../15.0.1.0.0/noupdate_changes.xml | 141 +++++++++++
.../migrations/15.0.1.0.0/post-migration.py | 17 ++
contract/models/abstract_contract_line.py | 23 +-
contract/models/contract.py | 32 +--
contract/models/contract_line.py | 102 ++++----
contract/models/contract_modification.py | 9 +-
contract/models/contract_recurrency_mixin.py | 8 +-
contract/models/res_company.py | 1 -
contract/static/description/index.html | 12 +-
contract/tests/test_contract.py | 55 ++--
contract/views/abstract_contract_line.xml | 2 +
contract/views/assets.xml | 40 ---
contract/views/contract.xml | 4 +
contract/wizards/contract_line_wizard.py | 7 +-
.../contract_manually_create_invoice.py | 2 +-
22 files changed, 510 insertions(+), 363 deletions(-)
create mode 100644 contract/migrations/15.0.1.0.0/noupdate_changes.xml
create mode 100644 contract/migrations/15.0.1.0.0/post-migration.py
delete mode 100644 contract/views/assets.xml
diff --git a/contract/README.rst b/contract/README.rst
index 1c38ac2dc..9d47cd057 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/14.0/contract
+ :target: https://github.com/OCA/contract/tree/15.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-14-0/contract-14-0-contract
+ :target: https://translation.odoo-community.org/projects/contract-15-0/contract-15-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/14.0
+ :target: https://runbot.odoo-community.org/runbot/110/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -76,9 +76,9 @@ Usage
* Contracts appear in portal to following users in every contract:
-.. image:: https://raw.githubusercontent.com/OCA/contract/14.0/contract/static/src/screenshots/portal-my.png
-.. image:: https://raw.githubusercontent.com/OCA/contract/14.0/contract/static/src/screenshots/portal-list.png
-.. image:: https://raw.githubusercontent.com/OCA/contract/14.0/contract/static/src/screenshots/portal-detail.png
+.. image:: https://raw.githubusercontent.com/OCA/contract/15.0/contract/static/src/screenshots/portal-my.png
+.. image:: https://raw.githubusercontent.com/OCA/contract/15.0/contract/static/src/screenshots/portal-list.png
+.. image:: https://raw.githubusercontent.com/OCA/contract/15.0/contract/static/src/screenshots/portal-detail.png
Known issues / Roadmap
======================
@@ -92,7 +92,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.
@@ -138,6 +138,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 4a3fb3af2..5e4245684 100644
--- a/contract/__manifest__.py
+++ b/contract/__manifest__.py
@@ -11,7 +11,7 @@
{
"name": "Recurring - Contracts Management",
- "version": "14.0.1.2.3",
+ "version": "15.0.1.0.0",
"category": "Contract Management",
"license": "AGPL-3",
"author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)",
@@ -35,7 +35,6 @@
"wizards/contract_manually_create_invoice.xml",
"wizards/contract_contract_terminate.xml",
"views/contract_tag.xml",
- "views/assets.xml",
"views/abstract_contract_line.xml",
"views/contract.xml",
"views/contract_line.xml",
@@ -46,5 +45,12 @@
"views/contract_terminate_reason.xml",
"views/contract_portal_templates.xml",
],
+ "assets": {
+ "web.assets_backend": [
+ "contract/static/src/js/section_and_note_fields_backend.js",
+ ],
+ "web.assets_frontend": ["contract/static/src/scss/frontend.scss"],
+ "web.assets_tests": ["contract/static/src/js/contract_portal_tour.js"],
+ },
"installable": True,
}
diff --git a/contract/data/mail_template.xml b/contract/data/mail_template.xml
index 209de8480..1a6f06666 100644
--- a/contract/data/mail_template.xml
+++ b/contract/data/mail_template.xml
@@ -4,93 +4,121 @@
Email Contract Template
${(object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '')|safe}
+ >{{ (object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '') }}
${object.company_id.name} Contract (Ref ${object.name or 'n/a'})
- ${object.partner_id.id}
+ >{{ object.company_id.name }} Contract (Ref {{ object.name or 'n/a' }})
+ {{ object.partner_id.id }}
Contract
- ${object.partner_id.lang}
-
- Hello ${object.partner_id.name or ''},
- A new contract has been created:
+ {{ object.partner_id.lang }}
+
+
+
Hello ,
+
A new contract has been created:
-
- REFERENCES
- Contract: ${object.name}
- % if object.date_start:
- Contract Date Start: ${object.date_start or ''}
- % endif
+
+ REFERENCES
+ Contract:
+
+ Contract Date Start:
+
- % if object.user_id:
- % if object.user_id.email:
- Your Contact: ${object.user_id.name}
- % else:
- Your Contact: ${object.user_id.name}
- % endif
- % endif
-
+
+
+ Your Contact:
+
+
+ Your Contact:
+
+
+
-
-
If you have any questions, do not hesitate to contact us.
-
Thank you for choosing ${object.company_id.name or 'us'}!
-
-
-
-
- ${object.company_id.name}
-
-
-
- ${object.company_id.partner_id.sudo().with_context(show_address=True, html_format=True).name_get()[0][1] | safe}
-
- % if object.company_id.phone:
-
- Phone: ${object.company_id.phone}
+
+
If you have any questions, do not hesitate to contact us.
+
Thank you for choosing !
+
+
+
+
+
+
+
+
+
+
+
+
+ Phone:
+
+
+
+
+
+
+
+
View contract
- % endif
- % if object.company_id.website:
-
- %endif
-
-
-
-
View contract
-
- ]]>
+
Contract Modification Template
${(object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '')|safe}
+ >{{ (object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '') }}
${object.company_id.name} Contract (Ref ${object.name or 'n/a'}) - Modifications
+ >{{ object.company_id.name }} Contract (Ref {{ object.name or 'n/a' }}) - Modifications
- ${object.partner_id.lang}
- {{ object.partner_id.lang }}
+
Hello
We have modifications on the contract that we want to notify you.
- ]]>
+
-
-
+
+
Hello
\n"
-" We have modifications on the contract that we want to notify you.
\n"
-" "
-msgstr ""
-
#. module: contract
#: model:mail.template,body_html:contract.email_contract_template
msgid ""
-"\n"
"\n"
-"
Hello ${object.partner_id.name or ''},
\n"
-"
A new contract has been created:
\n"
+"
Hello ,
\n"
+"
A new contract has been created:
\n"
"\n"
-"
\n"
-" REFERENCES \n"
-" Contract: ${object.name} \n"
-" % if object.date_start:\n"
-" Contract Date Start: ${object.date_start or ''} \n"
-" % endif\n"
+"
\n"
+" REFERENCES \n"
+" Contract: \n"
+" \n"
+" Contract Date Start: \n"
+" \n"
"\n"
-" % if object.user_id:\n"
-" % if object.user_id.email:\n"
-" Your Contact: ${object.user_id.name} \n"
-" % else:\n"
-" Your Contact: ${object.user_id.name}\n"
-" % endif\n"
-" % endif\n"
-"
\n"
+"
\n"
+" \n"
+" Your Contact: \n"
+" \n"
+" \n"
+" Your Contact: \n"
+" \n"
+" \n"
+" \n"
"\n"
-" \n"
-" If you have any questions, do not hesitate to contact us.
\n"
-" Thank you for choosing ${object.company_id.name or 'us'}!
\n"
-" \n"
-" \n"
-" \n"
-"
\n"
-" ${object.company_id.name} \n"
-" \n"
-" \n"
-"
\n"
-" ${object.company_id.partner_id.sudo().with_context(show_address=True, html_format=True).name_get()[0][1] | safe}\n"
-" \n"
-" % if object.company_id.phone:\n"
-"
\n"
-" Phone: ${object.company_id.phone}\n"
+"
\n"
+"
If you have any questions, do not hesitate to contact us.
\n"
+"
Thank you for choosing !
\n"
+"
\n"
+"
\n"
+"
\n"
+"
\n"
+" \n"
+" \n"
+"
\n"
+"
\n"
+" \n"
+" \n"
+"
\n"
+" \n"
+" Phone: \n"
+"
\n"
+" \n"
+"
\n"
+" \n"
+" \n"
+"
\n"
+"
\n"
+"
View contract \n"
"
\n"
-" % endif\n"
-" % if object.company_id.website:\n"
-"
\n"
-" %endif\n"
-"
\n"
-"
\n"
-"
\n"
-" View contract \n"
-" \n"
" "
msgstr ""
#. module: contract
-#: model:mail.template,subject:contract.email_contract_template
-msgid "${object.company_id.name} Contract (Ref ${object.name or 'n/a'})"
-msgstr ""
-
-#. module: contract
-#: model:mail.template,subject:contract.mail_template_contract_modification
+#: model:mail.template,body_html:contract.mail_template_contract_modification
msgid ""
-"${object.company_id.name} Contract (Ref ${object.name or 'n/a'}) - "
-"Modifications"
+"Hello
\n"
+" We have modifications on the contract that we want to notify you.
\n"
+" "
msgstr ""
#. module: contract
@@ -352,7 +338,6 @@ msgstr ""
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__is_auto_renew
#: model:ir.model.fields,field_description:contract.field_contract_line__is_auto_renew
-#: model:ir.model.fields,field_description:contract.field_contract_line_wizard__is_auto_renew
#: model:ir.model.fields,field_description:contract.field_contract_template_line__is_auto_renew
msgid "Auto Renew"
msgstr ""
@@ -405,6 +390,13 @@ msgstr ""
msgid "Canceled"
msgstr ""
+#. module: contract
+#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__product_uom_category_id
+#: model:ir.model.fields,field_description:contract.field_contract_line__product_uom_category_id
+#: model:ir.model.fields,field_description:contract.field_contract_template_line__product_uom_category_id
+msgid "Category"
+msgstr ""
+
#. module: contract
#: model_terms:ir.actions.act_window,help:contract.contract_template_action
msgid "Click to create a new contract template."
@@ -526,6 +518,11 @@ msgstr ""
msgid "Contract Modification"
msgstr ""
+#. module: contract
+#: model:mail.template,name:contract.mail_template_contract_modification
+msgid "Contract Modification Template"
+msgstr ""
+
#. module: contract
#: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view
msgid "Contract Name"
@@ -601,7 +598,7 @@ msgstr ""
#. module: contract
#: code:addons/contract/models/contract_line.py:0
#, python-format
-msgid "Contract line Un-canceled: %s - "
+msgid "Contract line Un-canceled: %s"
msgstr ""
#. module: contract
@@ -619,16 +616,16 @@ msgstr ""
#. module: contract
#: code:addons/contract/models/contract_line.py:0
#, python-format
-msgid "Contract line canceled: %s - "
+msgid "Contract line canceled: %s"
msgstr ""
#. module: contract
#: code:addons/contract/models/contract_line.py:0
#, python-format
msgid ""
-"Contract line for {product} \n"
+"Contract line for %(product)s \n"
" stopped: \n"
-" - End : {old_end} -- {new_end}\n"
+" - End : %(old_end)s -- %(new_end)s\n"
" "
msgstr ""
@@ -636,11 +633,11 @@ msgstr ""
#: code:addons/contract/models/contract_line.py:0
#, python-format
msgid ""
-"Contract line for {product} \n"
+"Contract line for %(product)s \n"
" planned a successor: \n"
-" - Start : {new_date_start}\n"
+" - Start : %(new_date_start)s\n"
" \n"
-" - End : {new_date_end}\n"
+" - End : %(new_date_end)s\n"
" "
msgstr ""
@@ -648,11 +645,11 @@ msgstr ""
#: code:addons/contract/models/contract_line.py:0
#, python-format
msgid ""
-"Contract line for {product} \n"
+"Contract line for %(product)s \n"
" renewed: \n"
-" - Start : {new_date_start}\n"
+" - Start : %(new_date_start)s\n"
" \n"
-" - End : {new_date_end}\n"
+" - End : %(new_date_end)s\n"
" "
msgstr ""
@@ -660,11 +657,11 @@ msgstr ""
#: code:addons/contract/models/contract_line.py:0
#, python-format
msgid ""
-"Contract line for {product} \n"
+"Contract line for %(product)s \n"
" suspended: \n"
-" - Suspension Start : {new_date_start}\n"
+" - Suspension Start : %(new_date_start)s\n"
" \n"
-" - Suspension End : {new_date_end}\n"
+" - Suspension End : %(new_date_end)s\n"
" "
msgstr ""
@@ -688,8 +685,8 @@ msgstr ""
#: code:addons/contract/models/contract.py:0
#, python-format
msgid ""
-"Contract manually invoiced: Invoice "
+"Contract manually invoiced: Invoice "
msgstr ""
#. module: contract
@@ -729,6 +726,15 @@ msgstr ""
msgid "Contracts to invoice"
msgstr ""
+#. module: contract
+#: model:ir.model.fields,help:contract.field_contract_abstract_contract_line__product_uom_category_id
+#: model:ir.model.fields,help:contract.field_contract_line__product_uom_category_id
+#: model:ir.model.fields,help:contract.field_contract_template_line__product_uom_category_id
+msgid ""
+"Conversion between Units of Measure can only occur if they belong to the "
+"same category. The conversion will be made based on the ratios."
+msgstr ""
+
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__create_invoice_visibility
#: model:ir.model.fields,field_description:contract.field_contract_line__create_invoice_visibility
@@ -929,25 +935,16 @@ msgid ""
msgstr ""
#. module: contract
-#: model:ir.model.fields,field_description:contract.field_account_move__display_name
-#: model:ir.model.fields,field_description:contract.field_account_move_line__display_name
-#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract__display_name
-#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__display_name
#: model:ir.model.fields,field_description:contract.field_contract_contract__display_name
#: model:ir.model.fields,field_description:contract.field_contract_contract_terminate__display_name
#: model:ir.model.fields,field_description:contract.field_contract_line__display_name
#: model:ir.model.fields,field_description:contract.field_contract_line_wizard__display_name
#: model:ir.model.fields,field_description:contract.field_contract_manually_create_invoice__display_name
#: model:ir.model.fields,field_description:contract.field_contract_modification__display_name
-#: model:ir.model.fields,field_description:contract.field_contract_recurrency_basic_mixin__display_name
-#: model:ir.model.fields,field_description:contract.field_contract_recurrency_mixin__display_name
#: model:ir.model.fields,field_description:contract.field_contract_tag__display_name
#: model:ir.model.fields,field_description:contract.field_contract_template__display_name
#: model:ir.model.fields,field_description:contract.field_contract_template_line__display_name
#: model:ir.model.fields,field_description:contract.field_contract_terminate_reason__display_name
-#: model:ir.model.fields,field_description:contract.field_res_company__display_name
-#: model:ir.model.fields,field_description:contract.field_res_config_settings__display_name
-#: model:ir.model.fields,field_description:contract.field_res_partner__display_name
msgid "Display Name"
msgstr ""
@@ -958,6 +955,11 @@ msgstr ""
msgid "Display Type"
msgstr ""
+#. module: contract
+#: model:mail.template,name:contract.email_contract_template
+msgid "Email Contract Template"
+msgstr ""
+
#. module: contract
#: model_terms:ir.ui.view,arch_db:contract.contract_contract_search_view
msgid "Finished"
@@ -973,11 +975,6 @@ msgstr ""
msgid "Followers"
msgstr ""
-#. module: contract
-#: model:ir.model.fields,field_description:contract.field_contract_contract__message_channel_ids
-msgid "Followers (Channels)"
-msgstr ""
-
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__message_partner_ids
msgid "Followers (Partners)"
@@ -1006,25 +1003,21 @@ msgid "Group By..."
msgstr ""
#. module: contract
-#: model:ir.model.fields,field_description:contract.field_account_move__id
-#: model:ir.model.fields,field_description:contract.field_account_move_line__id
-#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract__id
-#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__id
+#: model:ir.model.fields,field_description:contract.field_contract_contract__has_message
+msgid "Has Message"
+msgstr ""
+
+#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__id
#: model:ir.model.fields,field_description:contract.field_contract_contract_terminate__id
#: model:ir.model.fields,field_description:contract.field_contract_line__id
#: model:ir.model.fields,field_description:contract.field_contract_line_wizard__id
#: model:ir.model.fields,field_description:contract.field_contract_manually_create_invoice__id
#: model:ir.model.fields,field_description:contract.field_contract_modification__id
-#: model:ir.model.fields,field_description:contract.field_contract_recurrency_basic_mixin__id
-#: model:ir.model.fields,field_description:contract.field_contract_recurrency_mixin__id
#: model:ir.model.fields,field_description:contract.field_contract_tag__id
#: model:ir.model.fields,field_description:contract.field_contract_template__id
#: model:ir.model.fields,field_description:contract.field_contract_template_line__id
#: model:ir.model.fields,field_description:contract.field_contract_terminate_reason__id
-#: model:ir.model.fields,field_description:contract.field_res_company__id
-#: model:ir.model.fields,field_description:contract.field_res_config_settings__id
-#: model:ir.model.fields,field_description:contract.field_res_partner__id
msgid "ID"
msgstr ""
@@ -1161,6 +1154,11 @@ msgstr ""
msgid "Invoicing type"
msgstr ""
+#. module: contract
+#: model:ir.model.fields,field_description:contract.field_contract_line_wizard__is_auto_renew
+msgid "Is Auto Renew"
+msgstr ""
+
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__message_is_follower
msgid "Is Follower"
@@ -1206,25 +1204,16 @@ msgid "Last Date Invoiced"
msgstr ""
#. module: contract
-#: model:ir.model.fields,field_description:contract.field_account_move____last_update
-#: model:ir.model.fields,field_description:contract.field_account_move_line____last_update
-#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract____last_update
-#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line____last_update
#: model:ir.model.fields,field_description:contract.field_contract_contract____last_update
#: model:ir.model.fields,field_description:contract.field_contract_contract_terminate____last_update
#: model:ir.model.fields,field_description:contract.field_contract_line____last_update
#: model:ir.model.fields,field_description:contract.field_contract_line_wizard____last_update
#: model:ir.model.fields,field_description:contract.field_contract_manually_create_invoice____last_update
#: model:ir.model.fields,field_description:contract.field_contract_modification____last_update
-#: model:ir.model.fields,field_description:contract.field_contract_recurrency_basic_mixin____last_update
-#: model:ir.model.fields,field_description:contract.field_contract_recurrency_mixin____last_update
#: model:ir.model.fields,field_description:contract.field_contract_tag____last_update
#: model:ir.model.fields,field_description:contract.field_contract_template____last_update
#: model:ir.model.fields,field_description:contract.field_contract_template_line____last_update
#: model:ir.model.fields,field_description:contract.field_contract_terminate_reason____last_update
-#: model:ir.model.fields,field_description:contract.field_res_company____last_update
-#: model:ir.model.fields,field_description:contract.field_res_config_settings____last_update
-#: model:ir.model.fields,field_description:contract.field_res_partner____last_update
msgid "Last Modified on"
msgstr ""
@@ -1275,7 +1264,7 @@ msgstr ""
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_line__manual_renew_needed
#: model:ir.model.fields,field_description:contract.field_contract_line_wizard__manual_renew_needed
-msgid "Manual renew needed"
+msgid "Manual Renew Needed"
msgstr ""
#. module: contract
@@ -1504,7 +1493,8 @@ msgstr ""
#. module: contract
#: code:addons/contract/models/contract.py:0
#, python-format
-msgid "Please define a %s journal for the company '%s'."
+msgid ""
+"Please define a %(contract_type)s journal for the company '%(company)s'."
msgstr ""
#. module: contract
@@ -1931,6 +1921,11 @@ msgstr ""
msgid "Termination Notice Before"
msgstr ""
+#. module: contract
+#: model:ir.model.fields,field_description:contract.field_contract_line__termination_notice_date
+msgid "Termination Notice Date"
+msgstr ""
+
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_abstract_contract_line__termination_notice_rule_type
#: model:ir.model.fields,field_description:contract.field_contract_line__termination_notice_rule_type
@@ -1944,11 +1939,6 @@ msgstr ""
msgid "Termination Reason"
msgstr ""
-#. module: contract
-#: model:ir.model.fields,field_description:contract.field_contract_line__termination_notice_date
-msgid "Termination notice date"
-msgstr ""
-
#. module: contract
#: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view
msgid "This contract was terminated for the reason"
@@ -2162,3 +2152,15 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:contract.contract_contract_form_view
msgid "on"
msgstr ""
+
+#. module: contract
+#: model:mail.template,subject:contract.email_contract_template
+msgid "{{ object.company_id.name }} Contract (Ref {{ object.name or 'n/a' }})"
+msgstr ""
+
+#. module: contract
+#: model:mail.template,subject:contract.mail_template_contract_modification
+msgid ""
+"{{ object.company_id.name }} Contract (Ref {{ object.name or 'n/a' }}) - "
+"Modifications"
+msgstr ""
diff --git a/contract/i18n/hr_HR.po b/contract/i18n/hr_HR.po
index e0d1f07f9..69acb354b 100644
--- a/contract/i18n/hr_HR.po
+++ b/contract/i18n/hr_HR.po
@@ -1566,7 +1566,7 @@ msgstr ""
#: code:addons/contract/models/contract.py:0
#, fuzzy, python-format
msgid "Please define a %s journal for the company '%s'."
-msgstr "Molimo definirajte dnevnik prodaje za poduzeće '%s'."
+msgstr "Molimo definirajte dnevnik prodaje '%s' za poduzeće '%s'."
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__access_url
diff --git a/contract/i18n/it.po b/contract/i18n/it.po
index 01f9cba3a..3a70bf91c 100644
--- a/contract/i18n/it.po
+++ b/contract/i18n/it.po
@@ -1581,7 +1581,7 @@ msgstr "Pianificazione successore non permessa per questa riga"
#: code:addons/contract/models/contract.py:0
#, python-format
msgid "Please define a %s journal for the company '%s'."
-msgstr "Definire un registro vendite per l'azienda \"%s\"."
+msgstr "Definire un registro vendite %s per l'azienda \"%s\"."
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__access_url
diff --git a/contract/i18n/tr_TR.po b/contract/i18n/tr_TR.po
index b1602c026..2ff2bb420 100644
--- a/contract/i18n/tr_TR.po
+++ b/contract/i18n/tr_TR.po
@@ -1564,7 +1564,7 @@ msgstr ""
#: code:addons/contract/models/contract.py:0
#, fuzzy, python-format
msgid "Please define a %s journal for the company '%s'."
-msgstr "Lütfen '%s' şirketi için bir satış yevmiyesi tanımlayın."
+msgstr "Lütfen '%s' şirketi için bir satış yevmiyesi tanımlayın ('%s')."
#. module: contract
#: model:ir.model.fields,field_description:contract.field_contract_contract__access_url
diff --git a/contract/migrations/15.0.1.0.0/noupdate_changes.xml b/contract/migrations/15.0.1.0.0/noupdate_changes.xml
new file mode 100644
index 000000000..982397a33
--- /dev/null
+++ b/contract/migrations/15.0.1.0.0/noupdate_changes.xml
@@ -0,0 +1,141 @@
+
+
+
+
+ Email Contract Template
+ {{ (object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '') }}
+ {{ object.company_id.name }} Contract (Ref {{ object.name or 'n/a' }})
+ {{ object.partner_id.id }}
+
+
+
+ Contract
+ {{ object.partner_id.lang }}
+
+
+
Hello ,
+
A new contract has been created:
+
+
+ REFERENCES
+ Contract:
+
+ Contract Date Start:
+
+
+
+
+ Your Contact:
+
+
+ Your Contact:
+
+
+
+
+
+
If you have any questions, do not hesitate to contact us.
+
Thank you for choosing !
+
+
+
+
+
+
+
+
+
+
+
+
+ Phone:
+
+
+
+
+
+
+
+
View contract
+
+
+
+
+ Contract Modification Template
+ {{ (object.user_id.email and '%s <%s>' % (object.user_id.name, object.user_id.email) or '') }}
+ {{ object.company_id.name }} Contract (Ref {{ object.name or 'n/a' }}) - Modifications
+
+ {{ object.partner_id.lang }}
+
+ Hello
+ We have modifications on the contract that we want to notify you.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/contract/migrations/15.0.1.0.0/post-migration.py b/contract/migrations/15.0.1.0.0/post-migration.py
new file mode 100644
index 000000000..f1ccd6922
--- /dev/null
+++ b/contract/migrations/15.0.1.0.0/post-migration.py
@@ -0,0 +1,17 @@
+from openupgradelib import openupgrade
+
+
+@openupgrade.migrate()
+def migrate(env, version):
+ openupgrade.load_data(
+ env.cr, "contract", "migrations/15.0.1.0.0/noupdate_changes.xml"
+ )
+ openupgrade.delete_record_translations(
+ env.cr,
+ "contract",
+ [
+ "email_contract_template",
+ "mail_template_contract_modification",
+ "mail_notification_contract",
+ ],
+ )
diff --git a/contract/models/abstract_contract_line.py b/contract/models/abstract_contract_line.py
index 6ee8e229e..7b1a5313d 100644
--- a/contract/models/abstract_contract_line.py
+++ b/contract/models/abstract_contract_line.py
@@ -20,14 +20,22 @@ class ContractAbstractContractLine(models.AbstractModel):
name = fields.Text(string="Description", required=True)
quantity = fields.Float(default=1.0, required=True)
- uom_id = fields.Many2one("uom.uom", string="Unit of Measure")
+ product_uom_category_id = fields.Many2one( # Used for domain of field uom_id
+ comodel_name="uom.category",
+ related="product_id.uom_id.category_id",
+ )
+ uom_id = fields.Many2one(
+ comodel_name="uom.uom",
+ string="Unit of Measure",
+ domain="[('category_id', '=', product_uom_category_id)]",
+ )
automatic_price = fields.Boolean(
string="Auto-price?",
help="If this is marked, the price will be obtained automatically "
"applying the pricelist to the product. If not, you will be "
"able to introduce a manual price",
)
- specific_price = fields.Float(string="Specific Price")
+ specific_price = fields.Float()
price_unit = fields.Float(
string="Unit Price",
compute="_compute_price_unit",
@@ -45,7 +53,6 @@ class ContractAbstractContractLine(models.AbstractModel):
" It should be less or equal to 100",
)
sequence = fields.Integer(
- string="Sequence",
default=10,
help="Sequence of the contract line when displaying contracts",
)
@@ -76,7 +83,7 @@ class ContractAbstractContractLine(models.AbstractModel):
readonly=False,
copy=True,
)
- last_date_invoiced = fields.Date(string="Last Date Invoiced")
+ last_date_invoiced = fields.Date()
is_canceled = fields.Boolean(string="Canceled", default=False)
is_auto_renew = fields.Boolean(string="Auto Renew", default=False)
auto_renew_interval = fields.Integer(
@@ -157,6 +164,7 @@ class ContractAbstractContractLine(models.AbstractModel):
def _compute_date_start(self):
self._set_recurrence_field("date_start")
+ # pylint: disable=missing-return
@api.depends("contract_id.recurring_next_date", "contract_id.line_recurrence")
def _compute_recurring_next_date(self):
super()._compute_recurring_next_date()
@@ -232,13 +240,7 @@ class ContractAbstractContractLine(models.AbstractModel):
@api.onchange("product_id")
def _onchange_product_id(self):
- if not self.product_id:
- return {"domain": {"uom_id": []}}
-
vals = {}
- domain = {
- "uom_id": [("category_id", "=", self.product_id.uom_id.category_id.id)]
- }
if not self.uom_id or (
self.product_id.uom_id.category_id.id != self.uom_id.category_id.id
):
@@ -257,4 +259,3 @@ class ContractAbstractContractLine(models.AbstractModel):
vals["name"] = self.product_id.get_product_multiline_description_sale()
vals["price_unit"] = product.price
self.update(vals)
- return {"domain": domain}
diff --git a/contract/models/contract.py b/contract/models/contract.py
index 1ab653910..478d39a6f 100644
--- a/contract/models/contract.py
+++ b/contract/models/contract.py
@@ -89,6 +89,7 @@ class ContractContract(models.Model):
string="Invoicing contact",
comodel_name="res.partner",
ondelete="restrict",
+ domain="['|',('id', 'parent_of', partner_id), ('id', 'child_of', partner_id)]",
)
partner_id = fields.Many2one(
comodel_name="res.partner", inverse="_inverse_partner_id", required=True
@@ -299,7 +300,7 @@ class ContractContract(models.Model):
@api.depends(
"contract_line_ids.recurring_next_date",
"contract_line_ids.is_canceled",
- )
+ ) # pylint: disable=missing-return
def _compute_recurring_next_date(self):
for contract in self:
recurring_next_date = contract.contract_line_ids.filtered(
@@ -371,15 +372,6 @@ class ContractContract(models.Model):
else:
self.payment_term_id = partner.property_payment_term_id
self.invoice_partner_id = self.partner_id.address_get(["invoice"])["invoice"]
- return {
- "domain": {
- "invoice_partner_id": [
- "|",
- ("id", "parent_of", self.partner_id.id),
- ("id", "child_of", self.partner_id.id),
- ]
- }
- }
def _convert_contract_lines(self, contract):
self.ensure_one()
@@ -416,8 +408,14 @@ class ContractContract(models.Model):
)
if not journal:
raise ValidationError(
- _("Please define a %s journal for the company '%s'.")
- % (self.contract_type, self.company_id.name or "")
+ _(
+ "Please define a %(contract_type)s journal "
+ "for the company '%(company)s'."
+ )
+ % {
+ "contract_type": self.contract_type,
+ "company": self.company_id.name or "",
+ }
)
invoice_type = "out_invoice"
if self.contract_type == "purchase":
@@ -566,10 +564,16 @@ class ContractContract(models.Model):
self.message_post(
body=_(
"Contract manually invoiced: "
- 'Invoice'
+ " Invoice"
" "
)
- % (invoice._name, invoice.id)
+ % {
+ "model_name": invoice._name,
+ "rec_id": invoice.id,
+ }
)
return invoice
diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py
index b9152c424..3b10a1c26 100644
--- a/contract/models/contract_line.py
+++ b/contract/models/contract_line.py
@@ -22,9 +22,7 @@ class ContractLine(models.Model):
]
_order = "sequence,id"
- sequence = fields.Integer(
- string="Sequence",
- )
+ sequence = fields.Integer()
contract_id = fields.Many2one(
comodel_name="contract.contract",
string="Contract",
@@ -44,7 +42,6 @@ class ContractLine(models.Model):
date_start = fields.Date(required=True)
date_end = fields.Date(compute="_compute_date_end", store=True, readonly=False)
termination_notice_date = fields.Date(
- string="Termination notice date",
compute="_compute_termination_notice_date",
store=True,
copy=False,
@@ -72,7 +69,6 @@ class ContractLine(models.Model):
help="Contract Line origin of this one.",
)
manual_renew_needed = fields.Boolean(
- string="Manual renew needed",
default=False,
help="This flag is used to make a difference between a definitive stop"
"and temporary one for which a user is not able to plan a"
@@ -92,7 +88,6 @@ class ContractLine(models.Model):
string="Un-Cancel allowed?", compute="_compute_allowed"
)
state = fields.Selection(
- string="State",
selection=[
("upcoming", "Upcoming"),
("in-progress", "In-progress"),
@@ -109,12 +104,11 @@ class ContractLine(models.Model):
related="contract_id.active",
store=True,
readonly=True,
- default=True,
)
@api.depends(
"last_date_invoiced", "date_start", "date_end", "contract_id.last_date_invoiced"
- )
+ ) # pylint: disable=missing-return
def _compute_next_period_date_start(self):
"""Rectify next period date start if another line in the contract has been
already invoiced previously when the recurrence is by contract.
@@ -696,15 +690,15 @@ class ContractLine(models.Model):
)
if post_message:
msg = _(
- """Contract line for {product}
+ """Contract line for %(product)s
stopped:
- - End : {old_end} -- {new_end}
- """.format(
- product=rec.name,
- old_end=old_date_end,
- new_end=rec.date_end,
- )
- )
+ - End : %(old_end)s -- %(new_end)s
+ """
+ ) % {
+ "product": rec.name,
+ "old_end": old_date_end,
+ "new_end": rec.date_end,
+ }
rec.contract_id.message_post(body=msg)
else:
rec.write(
@@ -770,17 +764,17 @@ class ContractLine(models.Model):
contract_line |= new_line
if post_message:
msg = _(
- """Contract line for {product}
+ """Contract line for %(product)s
planned a successor:
- - Start : {new_date_start}
+ - Start : %(new_date_start)s
- - End : {new_date_end}
- """.format(
- product=rec.name,
- new_date_start=new_line.date_start,
- new_date_end=new_line.date_end,
- )
- )
+ - End : %(new_date_end)s
+ """
+ ) % {
+ "product": rec.name,
+ "new_date_start": new_line.date_start,
+ "new_date_end": new_line.date_end,
+ }
rec.contract_id.message_post(body=msg)
return contract_line
@@ -873,17 +867,17 @@ class ContractLine(models.Model):
post_message=False,
)
msg = _(
- """Contract line for {product}
+ """Contract line for %(product)s
suspended:
- - Suspension Start : {new_date_start}
+ - Suspension Start : %(new_date_start)s
- - Suspension End : {new_date_end}
- """.format(
- product=rec.name,
- new_date_start=date_start,
- new_date_end=date_end,
- )
- )
+ - Suspension End : %(new_date_end)s
+ """
+ ) % {
+ "product": rec.name,
+ "new_date_start": date_start,
+ "new_date_end": date_end,
+ }
rec.contract_id.message_post(body=msg)
return contract_line
@@ -893,10 +887,13 @@ class ContractLine(models.Model):
for contract in self.mapped("contract_id"):
lines = self.filtered(lambda l, c=contract: l.contract_id == c)
msg = _(
- """Contract line canceled: %s"""
- % " - ".join(
- ["%s " % name for name in lines.mapped("name")]
- )
+ "Contract line canceled: %s",
+ " - ".join(
+ [
+ "%(product)s " % {"product": name}
+ for name in lines.mapped("name")
+ ]
+ ),
)
contract.message_post(body=msg)
self.mapped("predecessor_contract_line_id").write(
@@ -910,10 +907,13 @@ class ContractLine(models.Model):
for contract in self.mapped("contract_id"):
lines = self.filtered(lambda l, c=contract: l.contract_id == c)
msg = _(
- """Contract line Un-canceled: %s"""
- % " - ".join(
- ["%s " % name for name in lines.mapped("name")]
- )
+ "Contract line Un-canceled: %s",
+ " - ".join(
+ [
+ "%(product)s " % {"product": name}
+ for name in lines.mapped("name")
+ ]
+ ),
)
contract.message_post(body=msg)
for rec in self:
@@ -1036,17 +1036,17 @@ class ContractLine(models.Model):
new_line = rec._renew_extend_line(date_end)
res |= new_line
msg = _(
- """Contract line for {product}
+ """Contract line for %(product)s
renewed:
- - Start : {new_date_start}
+ - Start : %(new_date_start)s
- - End : {new_date_end}
- """.format(
- product=rec.name,
- new_date_start=date_start,
- new_date_end=date_end,
- )
- )
+ - End : %(new_date_end)s
+ """
+ ) % {
+ "product": rec.name,
+ "new_date_start": date_start,
+ "new_date_end": date_end,
+ }
rec.contract_id.message_post(body=msg)
return res
diff --git a/contract/models/contract_modification.py b/contract/models/contract_modification.py
index 4446b422b..8028e00d9 100644
--- a/contract/models/contract_modification.py
+++ b/contract/models/contract_modification.py
@@ -10,8 +10,8 @@ class ContractModification(models.Model):
_description = "Contract Modification"
_order = "date desc"
- date = fields.Date(required=True, string="Date")
- description = fields.Text(required=True, string="Description")
+ date = fields.Date(required=True)
+ description = fields.Text(required=True)
contract_id = fields.Many2one(
string="Contract",
comodel_name="contract.contract",
@@ -19,10 +19,7 @@ class ContractModification(models.Model):
ondelete="cascade",
index=True,
)
- sent = fields.Boolean(
- string="Sent",
- default=False,
- )
+ sent = fields.Boolean(default=False)
@api.model_create_multi
def create(self, vals_list):
diff --git a/contract/models/contract_recurrency_mixin.py b/contract/models/contract_recurrency_mixin.py
index c7f7ad0c8..ac6e4d71b 100644
--- a/contract/models/contract_recurrency_mixin.py
+++ b/contract/models/contract_recurrency_mixin.py
@@ -47,7 +47,7 @@ class ContractRecurrencyBasicMixin(models.AbstractModel):
string="Invoice Every",
help="Invoice every (Days/Week/Month/Year)",
)
- date_start = fields.Date(string="Date Start")
+ date_start = fields.Date()
recurring_next_date = fields.Date(string="Date of Next Invoice")
@api.depends("recurring_invoicing_type", "recurring_rule_type")
@@ -80,7 +80,7 @@ class ContractRecurrencyMixin(models.AbstractModel):
recurring_next_date = fields.Date(
compute="_compute_recurring_next_date", store=True, readonly=False, copy=True
)
- date_end = fields.Date(string="Date End", index=True)
+ date_end = fields.Date(index=True)
next_period_date_start = fields.Date(
string="Next Period Start",
compute="_compute_next_period_date_start",
@@ -89,9 +89,7 @@ class ContractRecurrencyMixin(models.AbstractModel):
string="Next Period End",
compute="_compute_next_period_date_end",
)
- last_date_invoiced = fields.Date(
- string="Last Date Invoiced", readonly=True, copy=False
- )
+ last_date_invoiced = fields.Date(readonly=True, copy=False)
@api.depends("next_period_date_start")
def _compute_recurring_next_date(self):
diff --git a/contract/models/res_company.py b/contract/models/res_company.py
index c43e504ab..41be6d314 100644
--- a/contract/models/res_company.py
+++ b/contract/models/res_company.py
@@ -9,7 +9,6 @@ class ResCompany(models.Model):
_inherit = "res.company"
create_new_line_at_contract_line_renew = fields.Boolean(
- string="Create New Line At Contract Line Renew",
help="If checked, a new line will be generated at contract line renew "
"and linked to the original one as successor. The default "
"behavior is to extend the end date of the contract by a new "
diff --git a/contract/static/description/index.html b/contract/static/description/index.html
index 92c225099..1e18bc8db 100644
--- a/contract/static/description/index.html
+++ b/contract/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module enables contracts management with recurring
invoicing functions. Also you can print and send by email contract report.
It works for customer contract and supplier contracts.
@@ -425,9 +425,9 @@ To use it, just select the template on the contract and fields will be filled au
Contracts appear in portal to following users in every contract:
-
-
-
+
+
+
@@ -441,7 +441,7 @@ To use it, just select the template on the contract and fields will be filled au
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.
@@ -492,7 +492,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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/tests/test_contract.py b/contract/tests/test_contract.py
index a124603b1..f65caae97 100644
--- a/contract/tests/test_contract.py
+++ b/contract/tests/test_contract.py
@@ -3,6 +3,7 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+import logging
from collections import namedtuple
from datetime import timedelta
@@ -17,7 +18,7 @@ def to_date(date):
return fields.Date.to_date(date)
-class TestContractBase(common.SavepointCase):
+class TestContractBase(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@@ -252,8 +253,6 @@ class TestContract(TestContractBase):
def test_contract(self):
self.assertEqual(self.contract.recurring_next_date, to_date("2018-01-15"))
self.assertAlmostEqual(self.acct_line.price_subtotal, 50.0)
- res = self.acct_line._onchange_product_id()
- self.assertIn("uom_id", res["domain"])
self.acct_line.price_unit = 100.0
self.contract.partner_id = self.partner.id
self.contract.recurring_create_invoice()
@@ -489,11 +488,6 @@ class TestContract(TestContractBase):
self.acct_line._onchange_product_id()
self.assertEqual(self.acct_line.uom_id, self.acct_line.product_id.uom_id)
- def test_onchange_product_id(self):
- line = self.env["contract.line"].new()
- res = line._onchange_product_id()
- self.assertFalse(res["domain"]["uom_id"])
-
def test_no_pricelist(self):
self.contract.pricelist_id = False
self.acct_line.quantity = 2
@@ -565,8 +559,15 @@ class TestContract(TestContractBase):
test_value = contract_line[key]
try:
test_value = test_value.id
- except AttributeError:
- pass
+ except AttributeError as ae:
+ # This try/except is for relation fields.
+ # For normal fields, test_value would be
+ # str, float, int ... without id
+ logging.info(
+ "Ignored AttributeError ('%s' is not a relation field): %s",
+ key,
+ ae,
+ )
self.assertEqual(test_value, value)
def test_send_mail_contract(self):
@@ -581,21 +582,6 @@ class TestContract(TestContractBase):
self.contract._onchange_contract_type()
self.assertFalse(any(self.contract.contract_line_ids.mapped("automatic_price")))
- def test_contract_onchange_product_id_domain_blank(self):
- """It should return a blank UoM domain when no product."""
- line = self.env["contract.template.line"].new()
- res = line._onchange_product_id()
- self.assertFalse(res["domain"]["uom_id"])
-
- def test_contract_onchange_product_id_domain(self):
- """It should return UoM category domain."""
- line = self._add_template_line()
- res = line._onchange_product_id()
- self.assertEqual(
- res["domain"]["uom_id"][0],
- ("category_id", "=", self.product_1.uom_id.category_id.id),
- )
-
def test_contract_onchange_product_id_uom(self):
"""It should update the UoM for the line."""
line = self._add_template_line(
@@ -647,14 +633,17 @@ class TestContract(TestContractBase):
show_contract = self.partner.with_context(
contract_type="sale"
).act_show_contract()
- self.assertDictContainsSubset(
- {
- "name": "Customer Contracts",
- "type": "ir.actions.act_window",
- "res_model": "contract.contract",
- "xml_id": "contract.action_customer_contract",
- },
+ self.assertEqual(
show_contract,
+ {
+ **show_contract,
+ **{
+ "name": "Customer Contracts",
+ "type": "ir.actions.act_window",
+ "res_model": "contract.contract",
+ "xml_id": "contract.action_customer_contract",
+ },
+ },
"There was an error and the view couldn't be opened.",
)
@@ -2309,7 +2298,7 @@ class TestContract(TestContractBase):
action = self.contract.action_terminate_contract()
wizard = (
self.env[action["res_model"]]
- .with_context(action["context"])
+ .with_context(**action["context"])
.create(
{
"terminate_date": "2018-03-01",
diff --git a/contract/views/abstract_contract_line.xml b/contract/views/abstract_contract_line.xml
index 140ffb3fb..b385a8154 100644
--- a/contract/views/abstract_contract_line.xml
+++ b/contract/views/abstract_contract_line.xml
@@ -21,6 +21,8 @@
name="product_id"
attrs="{'required': [('display_type', '=', False)]}"
/>
+
+
diff --git a/contract/views/assets.xml b/contract/views/assets.xml
deleted file mode 100644
index bdd94fa3e..000000000
--- a/contract/views/assets.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/contract/views/contract.xml b/contract/views/contract.xml
index b8bc04c4d..b788f4289 100644
--- a/contract/views/contract.xml
+++ b/contract/views/contract.xml
@@ -202,6 +202,10 @@
+