[IMP] contract_price_revision: Allows to restrict price revision on some lines

As if recurrence management is per line, some lines should be excluded from price revision.
This commit is contained in:
Denis Roussel
2022-08-08 18:42:11 +02:00
committed by Carolina Fernandez
parent c5e1c9026c
commit 3c70ca799a
9 changed files with 142 additions and 45 deletions

View File

@@ -2,10 +2,13 @@
Contract Price Revision
=======================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c8a59ff02fbb6be23950f10dec81d9fac5d8dceb53a5213a9cce91789ca63230
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
@@ -14,14 +17,14 @@ Contract Price Revision
: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/12.0/contract_price_revision
:target: https://github.com/OCA/contract/tree/13.0/contract_price_revision
:alt: OCA/contract
.. |badge4| 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
:target: https://translation.odoo-community.org/projects/contract-13-0/contract-13-0-contract_price_revision
: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/12.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=13.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -50,13 +53,17 @@ To use this module:
#. When create invoices related to contracts selected, prices will be update
with the prices that are not out of date.
#. When managing contract with recurrence on line level, you maybe want not
to revise price for some lines.
Check 'Never Revise Price' on line level to avoid price revisions.
Bug Tracker
===========
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.
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:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract_price_revision%0Aversion:%2013.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.
@@ -66,6 +73,7 @@ Credits
Authors
~~~~~~~
* ACSONE SA/NV
* Tecnativa
Contributors
@@ -97,6 +105,6 @@ 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.
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/13.0/contract_price_revision>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -5,7 +5,7 @@
{
"name": "Contract Price Revision",
"summary": "Easy revision of contract prices",
"version": "13.0.1.0.0",
"version": "13.0.1.0.1",
"category": "Contract",
"author": "ACSONE SA/NV, Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",

View File

@@ -4,9 +4,9 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -23,6 +23,11 @@ msgstr ""
msgid "Cancel"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,help:contract_price_revision.field_contract_line__never_revise_price
msgid "Check this if you don't want to allow price revision."
msgstr ""
#. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_contract_line
msgid "Contract Line"
@@ -58,6 +63,11 @@ msgstr ""
msgid "Display Name"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__fixed_price
msgid "Fixed Price"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__id
msgid "ID"
@@ -78,28 +88,48 @@ msgstr ""
msgid "Last Updated on"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__never_revise_price
msgid "Never Revise Price"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__previous_price
msgid "Previous price"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__price_can_be_revised
msgid "Price Can Be Revised"
msgstr ""
#. module: contract_price_revision
#: 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"
" origin record.\n"
" <br/>\n"
" <br/>"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,help:contract_price_revision.field_contract_line__price_can_be_revised
msgid "Technical field in order to know if the line price can be revised."
msgstr ""
#. module: contract_price_revision
#: 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 %"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__variation_type
msgid "Variation Type"
msgstr ""
#. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_contract_price_revision_wizard
msgid "Wizard to update price based on percentage variation"
msgstr ""

View File

@@ -7,15 +7,15 @@ msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \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"
"PO-Revision-Date: 2023-07-20 09:11+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 1.8.7.1\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: contract_price_revision
#: model_terms:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
@@ -27,6 +27,11 @@ msgstr "Aplicar"
msgid "Cancel"
msgstr "Cancelar"
#. module: contract_price_revision
#: model:ir.model.fields,help:contract_price_revision.field_contract_line__never_revise_price
msgid "Check this if you don't want to allow price revision."
msgstr ""
#. module: contract_price_revision
#: model:ir.model,name:contract_price_revision.model_contract_line
msgid "Contract Line"
@@ -62,6 +67,11 @@ msgstr "Fecha inicio"
msgid "Display Name"
msgstr "Nombre mostrado"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__fixed_price
msgid "Fixed Price"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__id
msgid "ID"
@@ -75,18 +85,28 @@ msgstr "Última modificación en"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__write_uid
msgid "Last Updated by"
msgstr "Última modificación de"
msgstr "Última actualización por"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__write_date
msgid "Last Updated on"
msgstr "Última actualización en"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__never_revise_price
msgid "Never Revise Price"
msgstr ""
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__previous_price
msgid "Previous price"
msgstr "Precio anterior"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_line__price_can_be_revised
msgid "Price Can Be Revised"
msgstr ""
#. module: contract_price_revision
#: model_terms:ir.ui.view,arch_db:contract_price_revision.contract_line_duplicate_wizard_view
msgid ""
@@ -97,17 +117,29 @@ msgid ""
" <br/>"
msgstr ""
"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/>"
#. module: contract_price_revision
#: model:ir.model.fields,help:contract_price_revision.field_contract_line__price_can_be_revised
msgid "Technical field in order to know if the line price can be revised."
msgstr ""
#. module: contract_price_revision
#: 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 %"
msgstr "Variación %"
#. module: contract_price_revision
#: model:ir.model.fields,field_description:contract_price_revision.field_contract_price_revision_wizard__variation_type
msgid "Variation Type"
msgstr ""
#. module: contract_price_revision
#: 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"
msgstr ""
"Asistente para actualizar el precio basado en un porcentaje de variación"

View File

@@ -20,6 +20,9 @@ class ContractLine(models.Model):
string="Variation %",
)
never_revise_price = fields.Boolean(
help="Check this if you don't want to allow price revision."
)
price_can_be_revised = fields.Boolean(
compute="_compute_price_can_be_revised",
help="Technical field in order to know if the line price can be revised.",
@@ -29,7 +32,8 @@ class ContractLine(models.Model):
def _compute_price_can_be_revised(self):
date_start = self.env.context.get("date_start", fields.Datetime.now())
lines_can_be_revised = self.filtered(
lambda line: not line.automatic_price
lambda line: not line.never_revise_price
and not line.automatic_price
and not line.successor_contract_line_id
and line.recurring_next_date
and not line.display_type

View File

@@ -12,3 +12,7 @@ To use this module:
will have as ending date the day before the entered date.
#. When create invoices related to contracts selected, prices will be update
with the prices that are not out of date.
#. When managing contract with recurrence on line level, you maybe want not
to revise price for some lines.
Check 'Never Revise Price' on line level to avoid price revisions.

View File

@@ -3,18 +3,18 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Contract Price Revision</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
@@ -366,24 +366,26 @@ ul.auto-toc {
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c8a59ff02fbb6be23950f10dec81d9fac5d8dceb53a5213a9cce91789ca63230
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/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><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" 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 image-reference" href="https://github.com/OCA/contract/tree/13.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 image-reference" href="https://translation.odoo-community.org/projects/contract-13-0/contract-13-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/contract&amp;target_branch=13.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to create revisions of contract line prices.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To use this module:</p>
<ol class="arabic simple">
<li>Go to <strong>Invoicing &gt; Customers &gt; Customer Contracts</strong> if you are a billing
@@ -398,26 +400,30 @@ a price increased accordingly to the percent entered. Old contract lines
will have as ending date the day before the entered date.</li>
<li>When create invoices related to contracts selected, prices will be update
with the prices that are not out of date.</li>
<li>When managing contract with recurrence on line level, you maybe want not
to revise price for some lines.
Check Never Revise Price on line level to avoid price revisions.</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<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.
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:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
If you spotted it first, help us to smash 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:%2013.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>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>ACSONE SA/NV</li>
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Vicent Cubells</li>
@@ -427,15 +433,15 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</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><a class="reference external image-reference" 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/13.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>
</div>
</div>

View File

@@ -46,6 +46,17 @@ class TestContractPriceRevision(TestContractBase):
)
self.assertEqual(len(lines), 1)
def test_contract_price_fixed_revision_wizard_never(self):
self.acct_line.copy({"never_revise_price": True})
self.assertEqual(len(self.contract.contract_line_ids.ids), 2)
self._create_wizard(v_type="fixed", value=120.0)
self.execute_wizard()
self.assertEqual(len(self.contract.contract_line_ids.ids), 3)
lines = self.contract.contract_line_ids.filtered(
lambda x: x.price_unit == 120.0
)
self.assertEqual(len(lines), 1)
def test_contract_price_revision_invoicing(self):
self.acct_line.copy({"automatic_price": True})
self._create_wizard(value=100.0)

View File

@@ -5,6 +5,7 @@
<field name="inherit_id" ref="contract.contract_line_tree_view" />
<field name="arch" type="xml">
<field name="last_date_invoiced" position="after">
<field name="never_revise_price" />
<field name="variation_percent" groups="base.group_no_one" />
</field>
</field>
@@ -14,6 +15,7 @@
<field name="inherit_id" ref="contract.contract_line_form_view" />
<field name="arch" type="xml">
<field name="discount" position="after">
<field name="never_revise_price" />
<field
name="variation_percent"
groups="base.group_no_one"