[MIG] contract_variable_quantity: Migration to 16.0

This commit is contained in:
Carolina Fernandez
2024-01-05 10:59:50 -03:00
parent 276c86f9f3
commit ae8947af62
6 changed files with 35 additions and 28 deletions

View File

@@ -7,7 +7,7 @@ Variable quantity in contract recurrent invoicing
!! 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. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:648dc147c00023bfda1595708efb6802c3ae0216215f6f4922a667f890e3180f !! source digest: sha256:f186109da38da1bb524348308da9f6f58d233204f646f60e843ce133deeacf09
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Variable quantity in contract recurrent invoicing
: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 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github
:target: https://github.com/OCA/contract/tree/15.0/contract_variable_quantity :target: https://github.com/OCA/contract/tree/16.0/contract_variable_quantity
:alt: OCA/contract :alt: OCA/contract
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/contract-15-0/contract-15-0-contract_variable_quantity :target: https://translation.odoo-community.org/projects/contract-16-0/contract-16-0-contract_variable_quantity
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=15.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=16.0
:alt: Try me on Runboat :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -52,7 +52,7 @@ Configuration
* *contract*: Contract whose line belongs to. * *contract*: Contract whose line belongs to.
* *invoice*: Invoice (header) being created. * *invoice*: Invoice (header) being created.
.. figure:: https://raw.githubusercontent.com/OCA/contract/15.0/contract_variable_quantity/images/formula_form.png .. figure:: https://raw.githubusercontent.com/OCA/contract/16.0/contract_variable_quantity/images/formula_form.png
:alt: Formula form :alt: Formula form
:width: 600 px :width: 600 px
@@ -73,7 +73,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 to smash it by providing a detailed and welcomed 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_variable_quantity%0Aversion:%2015.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_variable_quantity%0Aversion:%2016.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.
@@ -93,6 +93,7 @@ Contributors
* Pedro M. Baeza * Pedro M. Baeza
* Carlos Roca * Carlos Roca
* Víctor Martínez * Víctor Martínez
* Carolina Fernandez
* Dave Lasley <dave@laslabs.com> * Dave Lasley <dave@laslabs.com>
* Souheil Bejaoui <souheil.bejaoui@acsone.eu> * Souheil Bejaoui <souheil.bejaoui@acsone.eu>
@@ -110,6 +111,6 @@ 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/15.0/contract_variable_quantity>`_ project on GitHub. This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/16.0/contract_variable_quantity>`_ 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.

View File

@@ -1,11 +1,12 @@
# Copyright 2016-2019 Tecnativa - Pedro M. Baeza # Copyright 2016-2019 Tecnativa - Pedro M. Baeza
# Copyright 2018 Tecnativa - Carlos Dauden # Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2019 ACSONE SA/NV # Copyright 2019 ACSONE SA/NV
# Copyright 2024 Tecnativa - Carolina fernandez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Variable quantity in contract recurrent invoicing", "name": "Variable quantity in contract recurrent invoicing",
"version": "15.0.1.0.0", "version": "16.0.1.0.0",
"category": "Contract Management", "category": "Contract Management",
"license": "AGPL-3", "license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)", "author": "Tecnativa, Odoo Community Association (OCA)",

View File

@@ -1,6 +1,7 @@
# Copyright 2016 Tecnativa - Pedro M. Baeza # Copyright 2016 Tecnativa - Pedro M. Baeza
# Copyright 2018 Tecnativa - Carlos Dauden # Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2018 ACSONE SA/NV # Copyright 2018 ACSONE SA/NV
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models from odoo import models
@@ -40,8 +41,8 @@ class AccountAnalyticInvoiceLine(models.Model):
quantity = eval_context.get("result", 0) quantity = eval_context.get("result", 0)
return quantity return quantity
def _prepare_invoice_line(self, move_form): def _prepare_invoice_line(self):
vals = super()._prepare_invoice_line(move_form) vals = super()._prepare_invoice_line()
if ( if (
"quantity" in vals "quantity" in vals
and self.contract_id.skip_zero_qty and self.contract_id.skip_zero_qty

View File

@@ -3,6 +3,7 @@
* Pedro M. Baeza * Pedro M. Baeza
* Carlos Roca * Carlos Roca
* Víctor Martínez * Víctor Martínez
* Carolina Fernandez
* Dave Lasley <dave@laslabs.com> * Dave Lasley <dave@laslabs.com>
* Souheil Bejaoui <souheil.bejaoui@acsone.eu> * Souheil Bejaoui <souheil.bejaoui@acsone.eu>

View File

@@ -367,9 +367,9 @@ 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. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:648dc147c00023bfda1595708efb6802c3ae0216215f6f4922a667f890e3180f !! source digest: sha256:f186109da38da1bb524348308da9f6f58d233204f646f60e843ce133deeacf09
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 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/15.0/contract_variable_quantity"><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-15-0/contract-15-0-contract_variable_quantity"><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=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external image-reference" 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 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/16.0/contract_variable_quantity"><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-16-0/contract-16-0-contract_variable_quantity"><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=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>With this module, you will be able to define in recurring contracts some <p>With this module, you will be able to define in recurring contracts some
lines with variable quantity according to a provided formula.</p> lines with variable quantity according to a provided formula.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@@ -405,7 +405,7 @@ float/integer value of the quantity to invoice in the variable result.</p>
</li> </li>
</ol> </ol>
<div class="figure"> <div class="figure">
<img alt="Formula form" src="https://raw.githubusercontent.com/OCA/contract/15.0/contract_variable_quantity/images/formula_form.png" style="width: 600px;" /> <img alt="Formula form" src="https://raw.githubusercontent.com/OCA/contract/16.0/contract_variable_quantity/images/formula_form.png" style="width: 600px;" />
</div> </div>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
@@ -424,7 +424,7 @@ float/integer value of the quantity to invoice in the variable result.</p>
<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 to smash it by providing a detailed and welcomed 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_variable_quantity%0Aversion:%2015.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_variable_quantity%0Aversion:%2016.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">
@@ -444,6 +444,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Pedro M. Baeza</li> <li>Pedro M. Baeza</li>
<li>Carlos Roca</li> <li>Carlos Roca</li>
<li>Víctor Martínez</li> <li>Víctor Martínez</li>
<li>Carolina Fernandez</li>
</ul> </ul>
</blockquote> </blockquote>
</li> </li>
@@ -460,7 +461,7 @@ If you spotted it first, help us to smash 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/15.0/contract_variable_quantity">OCA/contract</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/16.0/contract_variable_quantity">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>

View File

@@ -1,6 +1,7 @@
# Copyright 2016 Tecnativa - Pedro M. Baeza # Copyright 2016 Tecnativa - Pedro M. Baeza
# Copyright 2018 Tecnativa - Carlos Dauden # Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2018 ACSONE SA/NV # Copyright 2018 ACSONE SA/NV
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import exceptions from odoo import exceptions
@@ -10,18 +11,19 @@ from odoo.tests.common import TransactionCase
@tagged("post_install", "-at_install") @tagged("post_install", "-at_install")
class TestContractVariableQuantity(TransactionCase): class TestContractVariableQuantity(TransactionCase):
def setUp(self): @classmethod
super().setUp() def setUpClass(cls):
self.partner = self.env["res.partner"].create({"name": "Test partner"}) super().setUpClass()
self.product = self.env["product.product"].create({"name": "Test product"}) cls.partner = cls.env["res.partner"].create({"name": "Test partner"})
self.contract = self.env["contract.contract"].create( cls.product = cls.env["product.product"].create({"name": "Test product"})
cls.contract = cls.env["contract.contract"].create(
{ {
"name": "Test Contract", "name": "Test Contract",
"partner_id": self.partner.id, "partner_id": cls.partner.id,
"pricelist_id": self.partner.property_product_pricelist.id, "pricelist_id": cls.partner.property_product_pricelist.id,
} }
) )
self.formula = self.env["contract.line.qty.formula"].create( cls.formula = cls.env["contract.line.qty.formula"].create(
{ {
"name": "Test formula", "name": "Test formula",
# For testing each of the possible variables # For testing each of the possible variables
@@ -37,15 +39,15 @@ class TestContractVariableQuantity(TransactionCase):
"result = 12", "result = 12",
} }
) )
self.contract_line = self.env["contract.line"].create( cls.contract_line = cls.env["contract.line"].create(
{ {
"contract_id": self.contract.id, "contract_id": cls.contract.id,
"product_id": self.product.id, "product_id": cls.product.id,
"name": "Test", "name": "Test",
"qty_type": "variable", "qty_type": "variable",
"qty_formula_id": self.formula.id, "qty_formula_id": cls.formula.id,
"quantity": 1, "quantity": 1,
"uom_id": self.product.uom_id.id, "uom_id": cls.product.uom_id.id,
"price_unit": 100, "price_unit": 100,
"discount": 50, "discount": 50,
"recurring_rule_type": "monthly", "recurring_rule_type": "monthly",