Browse Source

[MIG] contract_price_revision: Migration to 12.0

pull/441/head
Carlos Dauden 5 years ago
parent
commit
23bf138fdd
  1. 34
      contract_price_revision/README.rst
  2. 13
      contract_price_revision/__manifest__.py
  3. 88
      contract_price_revision/i18n/contract_price_revision.pot
  4. 111
      contract_price_revision/i18n/es.po
  5. 3
      contract_price_revision/models/__init__.py
  6. 19
      contract_price_revision/models/account_analytic_account.py
  7. 39
      contract_price_revision/models/account_analytic_invoice_line.py
  8. 31
      contract_price_revision/models/contract_line.py
  9. 1
      contract_price_revision/readme/CONTRIBUTORS.rst
  10. 2
      contract_price_revision/readme/USAGE.rst
  11. 11
      contract_price_revision/static/description/index.html
  12. 74
      contract_price_revision/tests/test_contract_price_revision.py
  13. 43
      contract_price_revision/views/account_analytic_account_views.xml
  14. 26
      contract_price_revision/views/contract_line.xml
  15. 2
      contract_price_revision/wizards/__init__.py
  16. 54
      contract_price_revision/wizards/contract_price_revision.py
  17. 6
      contract_price_revision/wizards/contract_price_revision_views.xml
  18. 50
      contract_price_revision/wizards/create_revision_line.py

34
contract_price_revision/README.rst

@ -7,23 +7,20 @@ Contract Price Revision
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :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/11.0/contract_price_revision
.. |badge2| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github
:target: https://github.com/OCA/contract/tree/12.0/contract_price_revision
:alt: OCA/contract :alt: OCA/contract
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-contract_price_revision
.. |badge3| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract_price_revision
:alt: Translate me on Weblate :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/11.0
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/110/12.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4|
This module allows to create revisions of contract line prices. This module allows to create revisions of contract line prices.
@ -37,7 +34,7 @@ Usage
To use this module: To use this module:
#. Go to **Invoicing > Documents > Customer Contracts** if you are a billing
#. Go to **Invoicing > Customers > Customer Contracts** if you are a billing
user. user.
#. Select as many contracts as you want to update line prices. #. Select as many contracts as you want to update line prices.
#. Click on Action button and execute the wizard **Create revision of contract #. Click on Action button and execute the wizard **Create revision of contract
@ -56,7 +53,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/contract/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/contract/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract_price_revision%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract_price_revision%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -74,6 +71,7 @@ Contributors
* `Tecnativa <https://www.tecnativa.com>`_: * `Tecnativa <https://www.tecnativa.com>`_:
* Vicent Cubells * Vicent Cubells
* Carlos Dauden
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -88,6 +86,14 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/11.0/contract_price_revision>`_ project on GitHub.
.. |maintainer-carlosdauden| image:: https://github.com/carlosdauden.png?size=40px
:target: https://github.com/carlosdauden
:alt: carlosdauden
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-carlosdauden|
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/12.0/contract_price_revision>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

13
contract_price_revision/__manifest__.py

@ -1,10 +1,11 @@
# Copyright 2019 Tecnativa <vicent.cubells@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2019 Tecnativa - Vicent Cubells
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
'name': 'Contract Price Revision', 'name': 'Contract Price Revision',
'summary': 'Easy revision of contract prices', 'summary': 'Easy revision of contract prices',
'version': '11.0.1.0.0',
'version': '12.0.1.0.0',
'category': 'Contract', 'category': 'Contract',
'author': 'Tecnativa, ' 'author': 'Tecnativa, '
'Odoo Community Association (OCA)', 'Odoo Community Association (OCA)',
@ -14,8 +15,10 @@
'contract', 'contract',
], ],
'data': [ 'data': [
'wizards/create_revision_line_views.xml',
'views/account_analytic_account_views.xml',
'views/contract_line.xml',
'wizards/contract_price_revision_views.xml',
], ],
'installable': True, 'installable': True,
'development_status': 'Stable',
'maintainers': ['carlosdauden'],
} }

88
contract_price_revision/i18n/contract_price_revision.pot

@ -4,8 +4,10 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-17 11:19+0000\n"
"PO-Revision-Date: 2019-12-17 11:19+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -14,18 +16,18 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_account_analytic_account
msgid "Analytic Account"
#: model_terms:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid "Apply"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid "Apply"
#: model_terms:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid "Cancel"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid "Cancel"
#: model:ir.model,name:contract_price_revision.model_contract_line
msgid "Contract Line"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
@ -34,72 +36,57 @@ msgid "Create revision of contract lines"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_create_uid
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__create_uid
msgid "Created by" msgid "Created by"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_create_date
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__create_date
msgid "Created on" msgid "Created on"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_date_end
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__date_end
msgid "Date End" msgid "Date End"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_date_start
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__date_start
msgid "Date Start" msgid "Date Start"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_display_name
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__display_name
msgid "Display Name" msgid "Display Name"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_date_end
msgid "End Date"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_id
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__id
msgid "ID" msgid "ID"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard___last_update
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard____last_update
msgid "Last Modified on" msgid "Last Modified on"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_write_uid
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__write_uid
msgid "Last Updated by" msgid "Last Updated by"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_write_date
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__write_date
msgid "Last Updated on" msgid "Last Updated on"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.account_analytic_invoice_line_form_view
msgid "Line Information"
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__previous_price
msgid "Previous price"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_previous_revision_id
msgid "Previous revision"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,help:contract_price_revision.field_account_analytic_invoice_line_previous_revision_id
msgid "Relation with previous revision"
msgstr ""
#. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
#: model_terms:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid "Set new start date and variation percent to duplicate.\n" msgid "Set new start date and variation percent to duplicate.\n"
" This process set start date previous day as end date of\n" " This process set start date previous day as end date of\n"
" origin record.\n" " origin record.\n"
@ -108,38 +95,13 @@ msgid "Set new start date and variation percent to duplicate.\n"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_date_start
msgid "Start Date"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_previous_price
msgid "Unit Price"
msgstr ""
#. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.account_analytic_invoice_line_form_view
msgid "Validity"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_variation_percent
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_variation_percent
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__variation_percent
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__variation_percent
msgid "Variation %" msgid "Variation %"
msgstr "" msgstr ""
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_account_analytic_invoice_line
msgid "account.analytic.invoice.line"
msgstr ""
#. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_create_revision_line_wizard
msgid "create.revision.line.wizard"
msgstr ""
#. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.account_analytic_invoice_line_form_view
msgid "to"
#: model:ir.model,name:contract_price_revision.model_contract_price_revision_wizard
msgid "Wizard to update price based on percentage variation"
msgstr "" msgstr ""

111
contract_price_revision/i18n/es.po

@ -6,105 +6,89 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 11.0\n" "Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-03-01 07:58+0000\n"
"PO-Revision-Date: 2019-03-01 07:58+0000\n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2019-12-17 12:20+0100\n"
"PO-Revision-Date: 2019-12-17 12:22+0100\n"
"Last-Translator: Carlos Dauden <carlos.dauden@tecnativa.com>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: \n"
"Language: es\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n" "Plural-Forms: \n"
"X-Generator: Poedit 1.8.7.1\n"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_account_analytic_account
msgid "Analytic Account"
msgstr "Cuenta analítica"
#. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
#: model_terms:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid "Apply" msgid "Apply"
msgstr "Aplicar" msgstr "Aplicar"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
#: model_terms:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid "Cancel" msgid "Cancel"
msgstr "Cancelar" msgstr "Cancelar"
#. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_contract_line
msgid "Contract Line"
msgstr "Línea de contrato"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.actions.act_window,name:contract_price_revision.contract_line_duplicate_wizard_action #: model:ir.actions.act_window,name:contract_price_revision.contract_line_duplicate_wizard_action
msgid "Create revision of contract lines" msgid "Create revision of contract lines"
msgstr "Crear revisión de las líneas de contrato" msgstr "Crear revisión de las líneas de contrato"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_create_uid
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__create_uid
msgid "Created by" msgid "Created by"
msgstr "Creado por" msgstr "Creado por"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_create_date
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__create_date
msgid "Created on" msgid "Created on"
msgstr "Creado el" msgstr "Creado el"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_date_end
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__date_end
msgid "Date End" msgid "Date End"
msgstr "Fecha fin" msgstr "Fecha fin"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_date_start
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__date_start
msgid "Date Start" msgid "Date Start"
msgstr "Fecha inicio" msgstr "Fecha inicio"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_display_name
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__display_name
msgid "Display Name" msgid "Display Name"
msgstr "Nombre mostrado" msgstr "Nombre mostrado"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_date_end
msgid "End Date"
msgstr "Fecha fin"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_id
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__id
msgid "ID" msgid "ID"
msgstr "Id" msgstr "Id"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard___last_update
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard____last_update
msgid "Last Modified on" msgid "Last Modified on"
msgstr "Última modificación en" msgstr "Última modificación en"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_write_uid
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__write_uid
msgid "Last Updated by" msgid "Last Updated by"
msgstr "Última modificación de" msgstr "Última modificación de"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_write_date
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__write_date
msgid "Last Updated on" msgid "Last Updated on"
msgstr "Última actualización en" msgstr "Última actualización en"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.account_analytic_invoice_line_form_view
msgid "Line Information"
msgstr "Información de la línea"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_previous_revision_id
msgid "Previous revision"
msgstr "Revisión previa"
#. module: contract_price_revision
#: model:ir.model.fields,help:contract_price_revision.field_account_analytic_invoice_line_previous_revision_id
#, fuzzy
#| msgid "Relation with previous info"
msgid "Relation with previous revision"
msgstr "Relación con la información previa"
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__previous_price
msgid "Previous price"
msgstr "Precio anterior"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
#: model_terms:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid "" msgid ""
"Set new start date and variation percent to duplicate.\n" "Set new start date and variation percent to duplicate.\n"
" This process set start date previous day as end date of\n" " This process set start date previous day as end date of\n"
@ -113,46 +97,17 @@ msgid ""
" <br/>" " <br/>"
msgstr "" msgstr ""
"Establezca nueva fecha y porcentaje de variación para duplicar.\n" "Establezca nueva fecha y porcentaje de variación para duplicar.\n"
" Este proceso establece la fecha de inicio anterior "
"como fecha de finalización de registro de origen.\n"
" Este proceso establece la fecha de inicio anterior como fecha de finalización de registro de origen.\n"
"<br/>\n" "<br/>\n"
"<br/>" "<br/>"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_date_start
msgid "Start Date"
msgstr "Fecha de inicio"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_previous_price
msgid "Unit Price"
msgstr "Precio unidad"
#. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.account_analytic_invoice_line_form_view
msgid "Validity"
msgstr "Validez"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_account_analytic_invoice_line_variation_percent
#: model:ir.model.fields,field_description:contract_price_revision.field_create_revision_line_wizard_variation_percent
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__variation_percent
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__variation_percent
msgid "Variation %" msgid "Variation %"
msgstr "Varicación %"
msgstr "Variación %"
#. module: contract_price_revision #. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_account_analytic_invoice_line
msgid "account.analytic.invoice.line"
msgstr "account.analytic.invoice.line"
#. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_create_revision_line_wizard
msgid "create.revision.line.wizard"
msgstr "create.revision.line.wizard"
#. module: contract_price_revision
#: model:ir.ui.view,arch_db:contract_price_revision.account_analytic_invoice_line_form_view
msgid "to"
msgstr "hasta"
#~ msgid "or"
#~ msgstr "o"
#: model:ir.model,name:contract_price_revision.model_contract_price_revision_wizard
msgid "Wizard to update price based on percentage variation"
msgstr "Asistente para actualizar el precio basado en un porcentaje de variación"

3
contract_price_revision/models/__init__.py

@ -1,2 +1 @@
from . import account_analytic_account
from . import account_analytic_invoice_line
from . import contract_line

19
contract_price_revision/models/account_analytic_account.py

@ -1,19 +0,0 @@
# Copyright 2019 Tecnativa <vicent.cubells@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class AccountAnalyticAccount(models.Model):
_inherit = "account.analytic.account"
@api.model
def _prepare_invoice_line(self, line, invoice_id):
line_obj = self.env['account.invoice.line']
invoice = self.env['account.invoice'].browse(
invoice_id, prefetch=self._prefetch,
)
# Line with automatic price are not taken into account
if (line.date_start and invoice.date_invoice < line.date_start) or \
(line.date_end and invoice.date_invoice > line.date_end):
return line_obj
return super()._prepare_invoice_line(line, invoice_id)

39
contract_price_revision/models/account_analytic_invoice_line.py

@ -1,39 +0,0 @@
# Copyright 2019 Tecnativa <vicent.cubells@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
import odoo.addons.decimal_precision as dp
class AccountAnalyticINvoiceLine(models.Model):
_inherit = "account.analytic.invoice.line"
date_start = fields.Date(
string='Start Date',
)
date_end = fields.Date(
string='End Date',
)
previous_revision_id = fields.Many2one(
comodel_name='account.analytic.invoice.line',
string='Previous revision',
help='Relation with previous revision',
)
previous_price = fields.Float(
related='previous_revision_id.price_unit',
readonly=True,
)
variation_percent = fields.Float(
compute='_compute_variation_percent',
store=True,
digits=dp.get_precision('Product Price'),
string='Variation %',
)
@api.multi
@api.depends('price_unit', 'previous_revision_id.price_unit')
def _compute_variation_percent(self):
for line in self:
if not (line.price_unit and line.previous_price):
continue
line.variation_percent = (
(line.price_unit / line.previous_price - 1) * 100)

31
contract_price_revision/models/contract_line.py

@ -0,0 +1,31 @@
# Copyright 2019 Tecnativa - Vicent Cubells
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
import odoo.addons.decimal_precision as dp
class ContractLine(models.Model):
_inherit = 'contract.line'
previous_price = fields.Float(
string='Previous price',
related='predecessor_contract_line_id.price_unit',
readonly=True,
)
variation_percent = fields.Float(
compute='_compute_variation_percent',
store=True,
digits=dp.get_precision('Product Price'),
string='Variation %',
)
@api.depends('price_unit', 'predecessor_contract_line_id.price_unit')
def _compute_variation_percent(self):
for line in self:
if line.price_unit and line.previous_price:
line.variation_percent = (
(line.price_unit / line.previous_price - 1) * 100)
else:
line.variation_percent = 0.0

1
contract_price_revision/readme/CONTRIBUTORS.rst

@ -1,3 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_: * `Tecnativa <https://www.tecnativa.com>`_:
* Vicent Cubells * Vicent Cubells
* Carlos Dauden

2
contract_price_revision/readme/USAGE.rst

@ -1,6 +1,6 @@
To use this module: To use this module:
#. Go to **Invoicing > Documents > Customer Contracts** if you are a billing
#. Go to **Invoicing > Customers > Customer Contracts** if you are a billing
user. user.
#. Select as many contracts as you want to update line prices. #. Select as many contracts as you want to update line prices.
#. Click on Action button and execute the wizard **Create revision of contract #. Click on Action button and execute the wizard **Create revision of contract

11
contract_price_revision/static/description/index.html

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/contract/tree/11.0/contract_price_revision"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-contract_price_revision"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/110/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/contract/tree/12.0/contract_price_revision"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract_price_revision"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/110/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to create revisions of contract line prices.</p> <p>This module allows to create revisions of contract line prices.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
@ -386,7 +386,7 @@ ul.auto-toc {
<h1><a class="toc-backref" href="#id1">Usage</a></h1> <h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>To use this module:</p> <p>To use this module:</p>
<ol class="arabic simple"> <ol class="arabic simple">
<li>Go to <strong>Invoicing &gt; Documents &gt; Customer Contracts</strong> if you are a billing
<li>Go to <strong>Invoicing &gt; Customers &gt; Customer Contracts</strong> if you are a billing
user.</li> user.</li>
<li>Select as many contracts as you want to update line prices.</li> <li>Select as many contracts as you want to update line prices.</li>
<li>Click on Action button and execute the wizard <strong>Create revision of contract <li>Click on Action button and execute the wizard <strong>Create revision of contract
@ -405,7 +405,7 @@ with the prices that are not out of date.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/contract/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/contract/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20contract_price_revision%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20contract_price_revision%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -421,6 +421,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<ul class="simple"> <ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul> <li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Vicent Cubells</li> <li>Vicent Cubells</li>
<li>Carlos Dauden</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -432,7 +433,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/11.0/contract_price_revision">OCA/contract</a> project on GitHub.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/carlosdauden"><img alt="carlosdauden" src="https://github.com/carlosdauden.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/12.0/contract_price_revision">OCA/contract</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

74
contract_price_revision/tests/test_contract_price_revision.py

@ -1,71 +1,43 @@
# Copyright 2019 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2019 Tecnativa - Vicent Cubells
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from dateutil.relativedelta import relativedelta
from odoo.addons.contract.tests.test_contract import TestContractBase
from odoo.tests import common
from odoo import fields
class TestContractPriceRevision(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestContractPriceRevision, cls).setUpClass()
partner = cls.env['res.partner'].create({
'name': 'Partner test',
})
product = cls.env['product.product'].create({
'name': 'Test Product',
})
cls.contract = cls.env['account.analytic.account'].create({
'name': 'Contract test',
'partner_id': partner.id,
'date_start': fields.Date.today(),
'recurring_next_date': fields.Date.to_string(
fields.date.today() + relativedelta(days=7)),
'recurring_rule_type': 'monthly',
'recurring_invoice_line_ids': [(0, 0, {
'product_id': product.id,
'quantity': 1.0,
'uom_id': product.uom_id.id,
'name': product.name,
'price_unit': 33.0,
'automatic_price': True,
}), (0, 0, {
'product_id': product.id,
'quantity': 1.0,
'uom_id': product.uom_id.id,
'name': product.name,
'price_unit': 25.0,
'automatic_price': False,
})]
})
class TestContractPriceRevision(TestContractBase):
def execute_wizard(self): def execute_wizard(self):
wizard = self.env['create.revision.line.wizard'].create({
'date_start': fields.Date.today(),
'date_end': fields.Date.to_string(
fields.date.today() + relativedelta(years=1)),
wizard = self.env['contract.price.revision.wizard'].create({
'date_start': '2018-02-15',
'variation_percent': 100.0, 'variation_percent': 100.0,
}) })
wizard.with_context( wizard.with_context(
{'active_ids': [self.contract.id]}).action_apply() {'active_ids': [self.contract.id]}).action_apply()
def test_contract_price_revision_wizard(self): def test_contract_price_revision_wizard(self):
self.assertEqual(len(self.contract.recurring_invoice_line_ids.ids), 2)
self.acct_line.copy({'automatic_price': True})
self.assertEqual(len(self.contract.contract_line_ids.ids), 2)
self.execute_wizard() self.execute_wizard()
self.assertEqual(len(self.contract.recurring_invoice_line_ids.ids), 3)
lines = self.contract.mapped('recurring_invoice_line_ids').filtered(
lambda x: x.price_unit == 50.0)
self.assertEqual(len(self.contract.contract_line_ids.ids), 3)
lines = self.contract.contract_line_ids.filtered(
lambda x: x.price_unit == 200.0)
self.assertEqual(len(lines), 1) self.assertEqual(len(lines), 1)
def test_contract_price_revision_invoicing(self): def test_contract_price_revision_invoicing(self):
self.acct_line.copy({'automatic_price': True})
self.execute_wizard() self.execute_wizard()
self.contract.recurring_create_invoice()
invoice = self.contract.recurring_create_invoice()
invoices = self.env['account.invoice'].search([ invoices = self.env['account.invoice'].search([
('contract_id', '=', self.contract.id)])
('invoice_line_ids.contract_line_id', 'in',
self.contract.contract_line_ids.ids)])
self.assertEqual(len(invoices), 1) self.assertEqual(len(invoices), 1)
lines = invoices.mapped('invoice_line_ids')
lines = invoice.invoice_line_ids
self.assertEqual(len(lines), 2)
lines = lines.filtered(lambda x: x.price_unit == 100.0)
self.assertEqual(len(lines), 1)
invoice = self.contract.recurring_create_invoice()
lines = invoice.invoice_line_ids
self.assertEqual(len(lines), 2) self.assertEqual(len(lines), 2)
lines = lines.filtered(lambda x: x.price_unit == 50.0)
lines = lines.filtered(lambda x: x.price_unit == 200.0)
self.assertEqual(len(lines), 1) self.assertEqual(len(lines), 1)

43
contract_price_revision/views/account_analytic_account_views.xml

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="account_analytic_invoice_line_form_view" model="ir.ui.view">
<field name="name">account.analytic.invoice.line.view</field>
<field name="model">account.analytic.invoice.line</field>
<field name="arch" type="xml">
<form string="Line Information">
<group>
<group>
<field name="analytic_account_id"/>
<field name="automatic_price"/>
</group>
<group>
<field name="product_id"/>
<field name="name"/>
<field name="quantity"/>
<field name="uom_id"/>
<field name="price_unit"/>
<field name="variation_percent"/>
<label for="date_start" string="Validity"/>
<div><field name="date_start" class="oe_inline"/> to <field name="date_end" class="oe_inline"/></div>
<field name="discount"/>
<field name="price_subtotal"/>
</group>
</group>
</form>
</field>
</record>
<record id="account_analytic_account_recurring_form_form" model="ir.ui.view">
<field name="name">Contract form price revision</field>
<field name="model">account.analytic.account</field>
<field name="inherit_id" ref="contract.account_analytic_account_recurring_form_form"/>
<field name="arch" type="xml">
<field name="price_unit" position="after">
<field name="variation_percent" attrs="{'readonly': [('automatic_price', '=', True)]}"/>
<field name="date_start" attrs="{'readonly': [('automatic_price', '=', True)]}"/>
<field name="date_end" attrs="{'readonly': [('automatic_price', '=', True)]}"/>
</field>
</field>
</record>
</odoo>

26
contract_price_revision/views/contract_line.xml

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="contract_line_tree_view" model="ir.ui.view">
<field name="model">contract.line</field>
<field name="inherit_id" ref="contract.contract_line_tree_view"/>
<field name="arch" type="xml">
<field name="last_date_invoiced" position="after">
<field name="variation_percent" groups="base.group_no_one"/>
</field>
</field>
</record>
<record id="contract_line_form_view" model="ir.ui.view">
<field name="model">contract.line</field>
<field name="inherit_id" ref="contract.contract_line_form_view"/>
<field name="arch" type="xml">
<field name="discount" position="after">
<field name="variation_percent"
groups="base.group_no_one"
attrs="{'invisible': [('predecessor_contract_line_id', '=', False)]}"/>
</field>
</field>
</record>
</odoo>

2
contract_price_revision/wizards/__init__.py

@ -1 +1 @@
from . import create_revision_line
from . import contract_price_revision

54
contract_price_revision/wizards/contract_price_revision.py

@ -0,0 +1,54 @@
# Copyright 2019 Tecnativa - Vicent Cubells
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from dateutil.relativedelta import relativedelta
from odoo import fields, models
import odoo.addons.decimal_precision as dp
class ContractPriceRevisionWizard(models.TransientModel):
""" Update contract price based on percentage variation """
_name = 'contract.price.revision.wizard'
_description = "Wizard to update price based on percentage variation"
date_start = fields.Date(
required=True,
)
date_end = fields.Date()
variation_percent = fields.Float(
digits=dp.get_precision('Product Price'),
required=True,
string='Variation %',
)
def action_apply(self):
ContractLine = self.env['contract.line']
active_ids = self.env.context['active_ids']
for line in self.env['contract.contract'].browse(active_ids).mapped(
'contract_line_ids'):
if (line.automatic_price or line.successor_contract_line_id or
not line.recurring_next_date):
continue
line.update({
'date_end': self.date_start - relativedelta(days=1),
})
new_vals = line.copy_data({
'date_start': self.date_start,
'date_end': self.date_end,
'predecessor_contract_line_id': line.id,
'price_unit': line.price_unit * (
1.0 + self.variation_percent / 100.0),
})[0]
tmp_line = ContractLine.new(new_vals)
tmp_line._onchange_date_start()
new_line = ContractLine.create(
tmp_line._convert_to_write(tmp_line._cache))
line.update({
'successor_contract_line_id': new_line.id,
})
action = self.env['ir.actions.act_window'].for_xml_id(
'contract', 'action_customer_contract')
action['domain'] = [('id', 'in', active_ids)]
return action

6
contract_price_revision/wizards/create_revision_line_views.xml → contract_price_revision/wizards/contract_price_revision_views.xml

@ -3,7 +3,7 @@
<record id="contract_line_duplicate_wizard_view" model="ir.ui.view"> <record id="contract_line_duplicate_wizard_view" model="ir.ui.view">
<field name="name">Create Revision Line</field> <field name="name">Create Revision Line</field>
<field name="model">create.revision.line.wizard</field>
<field name="model">contract.price.revision.wizard</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form> <form>
<div> <div>
@ -31,8 +31,8 @@
<act_window id="contract_line_duplicate_wizard_action" <act_window id="contract_line_duplicate_wizard_action"
name="Create revision of contract lines" name="Create revision of contract lines"
src_model="account.analytic.account"
res_model="create.revision.line.wizard"
src_model="contract.contract"
res_model="contract.price.revision.wizard"
view_type="form" view_mode="form" view_type="form" view_mode="form"
key2="client_action_multi" target="new" key2="client_action_multi" target="new"
/> />

50
contract_price_revision/wizards/create_revision_line.py

@ -1,50 +0,0 @@
# Copyright 2019 Tecnativa <vicent.cubells@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
import odoo.addons.decimal_precision as dp
class CreateRevisionLineWizard(models.TransientModel):
_name = 'create.revision.line.wizard'
date_start = fields.Date(
required=True,
)
date_end = fields.Date()
variation_percent = fields.Float(
digits=dp.get_precision('Product Price'),
required=True,
string='Variation %',
)
@api.multi
def action_apply(self):
contract_obj = self.env['account.analytic.account']
line_obj = self.env['account.analytic.invoice.line']
active_ids = self.env.context['active_ids']
line_news = line_obj
for item in contract_obj.browse(active_ids).mapped(
'recurring_invoice_line_ids').filtered(
lambda x: not x.automatic_price):
line_news |= item.copy({
'date_start': self.date_start,
'date_end': self.date_end,
'previous_revision_id': item.id,
'price_unit': item.price_unit * (
1.0 + self.variation_percent / 100.0),
})
item.date_end = (fields.Date.from_string(self.date_start) -
relativedelta(days=1))
action = self.env.ref(
'contract.action_account_analytic_sale_overdue_all').read()[0]
if len(active_ids) > 1: # pragma: no cover
action['domain'] = [('id', 'in', active_ids)]
elif active_ids:
action['views'] = [(
self.env.ref('contract.account_analytic_account_sale_form').id,
'form')]
action['res_id'] = active_ids[0]
return action
Loading…
Cancel
Save