Skip to content

Commit

Permalink
[MIG] account_invoice_supplierinfo_update_qty_multiplier: Migration t…
Browse files Browse the repository at this point in the history
…o 16.0
  • Loading branch information
legalsylvain committed Jun 20, 2024
1 parent 8d6ce59 commit a8d5f57
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 94 deletions.
10 changes: 5 additions & 5 deletions account_invoice_supplierinfo_update_qty_multiplier/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Account Invoice - Quantity Multiplier Update
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/12.0/account_invoice_supplierinfo_update_qty_multiplier
:target: https://github.com/OCA/account-invoicing/tree/16.0/account_invoice_supplierinfo_update_qty_multiplier
:alt: OCA/account-invoicing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoicing-12-0/account-invoicing-12-0-account_invoice_supplierinfo_update_qty_multiplier
:target: https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_invoice_supplierinfo_update_qty_multiplier
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=12.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-invoicing&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -47,7 +47,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
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
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_supplierinfo_update_qty_multiplier%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_supplierinfo_update_qty_multiplier%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.

Expand Down Expand Up @@ -80,6 +80,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-legalsylvain|

This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/12.0/account_invoice_supplierinfo_update_qty_multiplier>`_ project on GitHub.
This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/16.0/account_invoice_supplierinfo_update_qty_multiplier>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "Account Invoice - Quantity Multiplier Update",
"summary": "In the invoice Supplierinfo wizard,"
" allow to change the Quantity Multiplier field",
"version": "12.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"website": "https://github.com/OCA/account-invoicing",
"author": "GRAP,Odoo Community Association (OCA)",
Expand Down
15 changes: 7 additions & 8 deletions account_invoice_supplierinfo_update_qty_multiplier/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-03-08 15:17+0000\n"
"PO-Revision-Date: 2023-03-08 15:17+0000\n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2024-01-28 21:34+0000\n"
"PO-Revision-Date: 2024-01-28 21:34+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand All @@ -21,9 +21,9 @@ msgid "Current Multiplier Qty"
msgstr "Conditionnement"

#. module: account_invoice_supplierinfo_update_qty_multiplier
#: model:ir.model,name:account_invoice_supplierinfo_update_qty_multiplier.model_account_invoice_line
msgid "Invoice Line"
msgstr "Ligne de facture"
#: model:ir.model,name:account_invoice_supplierinfo_update_qty_multiplier.model_account_move_line
msgid "Journal Item"
msgstr "Écriture comptable"

#. module: account_invoice_supplierinfo_update_qty_multiplier
#: model:ir.model.fields,field_description:account_invoice_supplierinfo_update_qty_multiplier.field_wizard_update_invoice_supplierinfo_line__new_multiplier_qty
Expand All @@ -34,4 +34,3 @@ msgstr "Nouveau conditionnement"
#: model:ir.model,name:account_invoice_supplierinfo_update_qty_multiplier.model_wizard_update_invoice_supplierinfo_line
msgid "Wizard Line to update supplierinfo"
msgstr ""

Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import account_invoice_line
from . import account_move_line
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models
from odoo import models


class AccountInvoiceLine(models.Model):
_inherit = "account.invoice.line"
class AccountMoveLine(models.Model):
_inherit = "account.move.line"

@api.multi
def _prepare_supplier_wizard_line(self, supplierinfo):
res = super()._prepare_supplier_wizard_line(supplierinfo)
res["current_multiplier_qty"] = res["new_multiplier_qty"] = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ <h1 class="title">Account Invoice - Quantity Multiplier Update</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a248390afd4729a601c357232005eebd0508dced33fabde10661ca04383750f7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/account-invoicing/tree/12.0/account_invoice_supplierinfo_update_qty_multiplier"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-12-0/account-invoicing-12-0-account_invoice_supplierinfo_update_qty_multiplier"><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/account-invoicing&amp;target_branch=12.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/account-invoicing/tree/16.0/account_invoice_supplierinfo_update_qty_multiplier"><img alt="OCA/account-invoicing" src="https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-invoicing-16-0/account-invoicing-16-0-account_invoice_supplierinfo_update_qty_multiplier"><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/account-invoicing&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>This module is a glue module installed if the following module are installed:</p>
<ul class="simple">
<li><tt class="docutils literal">account_invoice_supplierinfo_update</tt> (same repository)</li>
Expand All @@ -392,7 +392,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-invoicing/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 to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_supplierinfo_update_qty_multiplier%0Aversion:%2012.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/account-invoicing/issues/new?body=module:%20account_invoice_supplierinfo_update_qty_multiplier%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>
</div>
<div class="section" id="credits">
Expand All @@ -412,7 +412,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Maintainers</a></h2>
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 image-reference" href="https://github.com/legalsylvain"><img alt="legalsylvain" src="https://github.com/legalsylvain.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-invoicing/tree/12.0/account_invoice_supplierinfo_update_qty_multiplier">OCA/account-invoicing</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-invoicing/tree/16.0/account_invoice_supplierinfo_update_qty_multiplier">OCA/account-invoicing</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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,56 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from datetime import datetime
from odoo.tests import tagged

from odoo.tests.common import TransactionCase
from odoo.addons.account_invoice_supplierinfo_update.tests.test_module import TestModule


class TestModule(TransactionCase):
def setUp(self):
super().setUp()
self.AccountInvoice = self.env["account.invoice"]
self.WizardUpdate = self.env["wizard.update.invoice.supplierinfo"]
self.SupplierInfo = self.env["product.supplierinfo"]

self.product1 = self.env.ref("product.product_product_4b")
unit = self.env.ref("uom.product_uom_unit")
account_id = (
self.env["account.account"]
.search([("user_type_id.type", "=", "payable")], limit=1)
.id
)
journal_id = (
self.env["account.journal"].search([("type", "=", "purchase")], limit=1).id
)
product_account_id = self.env.ref("account.demo_coffee_machine_account").id

self.invoice = self.AccountInvoice.create(
@tagged("post_install", "-at_install")
class TestModule(TestModule):
def test_supplierinfo_update_multiplier_qty(self):
self.ProductSupplierinfo.create(
{
"journal_id": journal_id,
"partner_id": self.env.ref("base.res_partner_12").id,
"account_id": account_id,
"date_invoice": "%s-01-01" % datetime.now().year,
"invoice_line_ids": [
(
0,
0,
{
"product_id": self.product1.id,
"name": "iPad Retina Display",
"quantity": 10.0,
"price_unit": 400.0,
"uom_id": unit.id,
"account_id": product_account_id,
},
)
],
"partner_id": self.invoice.supplier_partner_id.id,
"product_tmpl_id": self.product_a.product_tmpl_id.id,
"multiplier_qty": 15.0,
}
)

# Test Section
def test_wizard(self):
# Launch and confirm Wizard
lines_for_update = self.invoice._get_update_supplierinfo_lines()
wizard = self.WizardUpdate.with_context(
default_line_ids=lines_for_update, default_invoice_id=self.invoice.id
).create({})
wizard.line_ids[0].new_multiplier_qty = 55
vals_wizard = self.invoice.check_supplierinfo().get("context", {})

line_ids = vals_wizard.get("default_line_ids", {})

self.assertEqual(len(line_ids), 2)
self.assertEqual(line_ids[0][2]["current_multiplier_qty"], 15.0)
self.assertEqual(line_ids[0][2]["new_multiplier_qty"], 15.0)
self.assertEqual(line_ids[1][2]["current_multiplier_qty"], False)
self.assertEqual(line_ids[1][2]["new_multiplier_qty"], False)

line_ids[0][2]["new_multiplier_qty"] = 12.0
line_ids[1][2]["new_multiplier_qty"] = 14.0

# Create and launch update process
wizard = self.WizardUpdateSupplierinfo.create(
{"line_ids": line_ids, "invoice_id": self.invoice.id}
)

wizard.update_supplierinfo()

# Check Regressions
supplierinfo = self.SupplierInfo.search(
supplierinfo_a = self.ProductSupplierinfo.search(
[
("product_tmpl_id", "=", self.product1.product_tmpl_id.id),
("name", "=", self.invoice.partner_id.id),
("partner_id", "=", self.invoice.supplier_partner_id.id),
("product_tmpl_id", "=", self.product_a.product_tmpl_id.id),
]
)
self.assertEqual(len(supplierinfo_a), 1)
self.assertEqual(supplierinfo_a.multiplier_qty, 12.0)

self.assertEqual(
len(supplierinfo),
1,
"Regression : Confirming wizard should have create a supplierinfo",
)

self.assertEqual(
supplierinfo.multiplier_qty,
55,
"Confirming wizard should have update Multiplier Qty field.",
supplierinfo_b = self.ProductSupplierinfo.search(
[
("partner_id", "=", self.invoice.supplier_partner_id.id),
("product_tmpl_id", "=", self.product_b.product_tmpl_id.id),
]
)
self.assertEqual(len(supplierinfo_b), 1)
self.assertEqual(supplierinfo_b.multiplier_qty, 14.0)
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
>
<field
name="current_multiplier_qty"
attrs="{
'invisible': [('supplierinfo_id', '=', False)],
}"
optional="show"
attrs="{'invisible': [('supplierinfo_id', '=', False)]}"
/>
<field name="new_multiplier_qty" />
<field name="new_multiplier_qty" optional="show" />
</xpath>
</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
from odoo import fields, models


class WizardUpdateInvoiceSupplierinfoLine(models.TransientModel):
_inherit = "wizard.update.invoice.supplierinfo.line"

current_multiplier_qty = fields.Float(
string="Current Multiplier Qty", readonly=True
)
current_multiplier_qty = fields.Float(readonly=True)

new_multiplier_qty = fields.Float(string="New Multiplier Qty", required=True)
new_multiplier_qty = fields.Float(required=True)

@api.multi
def _prepare_supplierinfo_update(self):
res = super()._prepare_supplierinfo_update()
res["multiplier_qty"] = self.new_multiplier_qty
Expand Down

0 comments on commit a8d5f57

Please sign in to comment.