Skip to content

Commit

Permalink
[MIG] purchase_invoice_plan: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rlimaeco committed Feb 7, 2025
1 parent 86611b3 commit da92227
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 41 deletions.
33 changes: 16 additions & 17 deletions purchase_invoice_plan/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Purchase Invoice Plan
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/17.0/purchase_invoice_plan
:target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_invoice_plan
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-17-0/purchase-workflow-17-0-purchase_invoice_plan
:target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_invoice_plan
: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/purchase-workflow&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -46,23 +46,22 @@ either all at once, or one by one.
Usage
=====

- Create new purchase quotation as per normal process
- Select option "Use Invoice Plan", a new Invoice Plan tab will appear
- Click on "=> Create Invoice Plan" link to open invoice planning
wizard
- Do plan for number of installment, start date and interval
- Double check that each installment has correct plan percentage
- After confirm purchases order, we have new option to "Create Bill by
Plan"
- User can create only next bill or create all bills at the same time
- Create new purchase quotation as per normal process
- Select option "Use Invoice Plan", a new Invoice Plan tab will appear
- Click on "=> Create Invoice Plan" link to open invoice planning wizard
- Do plan for number of installment, start date and interval
- Double check that each installment has correct plan percentage
- After confirm purchases order, we have new option to "Create Bill by
Plan"
- User can create only next bill or create all bills at the same time

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/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/purchase-workflow/issues/new?body=module:%20purchase_invoice_plan%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_invoice_plan%0Aversion:%2018.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 All @@ -77,9 +76,9 @@ Authors
Contributors
------------

- Kitti Upariphutthiphong <[email protected]>
- Rattapong Chokmasermkul <[email protected]>
- Italo Lopes <[email protected]>
- Kitti Upariphutthiphong <[email protected]>
- Rattapong Chokmasermkul <[email protected]>
- Italo Lopes <[email protected]>

Maintainers
-----------
Expand All @@ -102,6 +101,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-kittiu|

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/17.0/purchase_invoice_plan>`_ project on GitHub.
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/18.0/purchase_invoice_plan>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion purchase_invoice_plan/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Purchase Invoice Plan",
"summary": "Add to purchases order, ability to manage future invoice plan",
"version": "17.0.1.0.1",
"version": "18.0.1.0.0",
"author": "Ecosoft,Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/purchase-workflow",
Expand Down
21 changes: 14 additions & 7 deletions purchase_invoice_plan/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dateutil.relativedelta import relativedelta

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools.float_utils import float_compare, float_round

Expand Down Expand Up @@ -56,20 +56,24 @@ def _check_ip_total_percent(self):
installments = rec.invoice_plan_ids.filtered("installment")
ip_total_percent = sum(installments.mapped("percent"))
if float_round(ip_total_percent, 0) > 100:
raise UserError(_("Invoice plan total percentage must not exceed 100%"))
raise UserError(
self.env._("Invoice plan total percentage must not exceed 100%")
)

@api.constrains("state")
def _check_invoice_plan(self):
for rec in self:
if rec.state != "draft":
if rec.invoice_plan_ids.filtered(lambda pln: not pln.percent):
raise ValidationError(
_("Please fill percentage for all invoice plan lines")
self.env._("Please fill percentage for all invoice plan lines")
)

def button_confirm(self):
if self.filtered(lambda r: r.use_invoice_plan and not r.invoice_plan_ids):
raise UserError(_("Use Invoice Plan selected, but no plan created"))
raise UserError(
self.env._("Use Invoice Plan selected, but no plan created")
)
return super().button_confirm()

def create_invoice_plan(
Expand Down Expand Up @@ -298,9 +302,12 @@ def _update_new_quantity(self, line, percent):
"""Hook function"""
plan_qty = self._get_plan_qty(line.purchase_line_id, percent)
prec = line.purchase_line_id.product_uom.rounding
if float_compare(abs(plan_qty), abs(line.quantity), prec) == 1:
if (
float_compare(abs(plan_qty), abs(line.quantity), precision_rounding=prec)
== 1
):
raise ValidationError(
_(
self.env._(
"Plan quantity: %(plan)s, exceed invoiceable quantity: %(qty)s"
"\nProduct should be delivered before invoice"
)
Expand All @@ -319,7 +326,7 @@ def _unlink_except_no_edit(self):
if lines:
installments = [str(x) for x in lines.mapped("installment")]
raise UserError(
_(
self.env._(
"Installment %s: already used and not allowed to delete.\n"
"Please discard changes."
)
Expand Down
6 changes: 3 additions & 3 deletions purchase_invoice_plan/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_purchase_invoice_plan,access_purchase_invoice_plan,model_purchase_invoice_plan,,1,1,1,1
access_purchase_create_invoice_plan,access_purchase_create_invoice_plan,model_purchase_create_invoice_plan,,1,1,1,1
access_purchase_make_planned_invoice,access_purchase_make_planned_invoice,model_purchase_make_planned_invoice,,1,1,1,1
access_purchase_invoice_plan,access_purchase_invoice_plan,model_purchase_invoice_plan,purchase.group_purchase_user,1,1,1,1
access_purchase_create_invoice_plan,access_purchase_create_invoice_plan,model_purchase_create_invoice_plan,purchase.group_purchase_user,1,1,1,1
access_purchase_make_planned_invoice,access_purchase_make_planned_invoice,model_purchase_make_planned_invoice,purchase.group_purchase_user,1,1,1,1
9 changes: 4 additions & 5 deletions purchase_invoice_plan/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ <h1 class="title">Purchase Invoice Plan</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5e33775e57e9e7ff1c71964816457b1d58330eee3583caaff9448e1233e88b17
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.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/purchase-workflow/tree/17.0/purchase_invoice_plan"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-17-0/purchase-workflow-17-0-purchase_invoice_plan"><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/purchase-workflow&amp;target_branch=17.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="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.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/purchase-workflow/tree/18.0/purchase_invoice_plan"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_invoice_plan"><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/purchase-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>By standard feature, user can gradually create partial invoices, one by
one and in step create invoice the standard call invoice. This module
add ability to create invoices based on the predefined invoice plan,
Expand Down Expand Up @@ -397,8 +397,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<ul class="simple">
<li>Create new purchase quotation as per normal process</li>
<li>Select option “Use Invoice Plan”, a new Invoice Plan tab will appear</li>
<li>Click on “=&gt; Create Invoice Plan” link to open invoice planning
wizard</li>
<li>Click on “=&gt; Create Invoice Plan” link to open invoice planning wizard</li>
<li>Do plan for number of installment, start date and interval</li>
<li>Double check that each installment has correct plan percentage</li>
<li>After confirm purchases order, we have new option to “Create Bill by
Expand All @@ -411,7 +410,7 @@ <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/purchase-workflow/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/purchase-workflow/issues/new?body=module:%20purchase_invoice_plan%0Aversion:%2017.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/purchase-workflow/issues/new?body=module:%20purchase_invoice_plan%0Aversion:%2018.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 Down Expand Up @@ -439,7 +438,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">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/kittiu"><img alt="kittiu" src="https://github.com/kittiu.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/17.0/purchase_invoice_plan">OCA/purchase-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/18.0/purchase_invoice_plan">OCA/purchase-workflow</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
2 changes: 1 addition & 1 deletion purchase_invoice_plan/tests/test_purchase_invoice_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from odoo import fields
from odoo.exceptions import UserError, ValidationError
from odoo.tests.common import Form, TransactionCase
from odoo.tests import Form, TransactionCase


class TestPurchaseInvoicePlan(TransactionCase):
Expand Down
9 changes: 4 additions & 5 deletions purchase_invoice_plan/views/purchase_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<field name="name">view.purchase.invoice.plan.tree</field>
<field name="model">purchase.invoice.plan</field>
<field name="arch" type="xml">
<tree editable="bottom">
<list editable="bottom">
<field name="no_edit" column_invisible="1" />
<field name="installment" readonly="no_edit == True" />
<field name="plan_date" readonly="no_edit == True" />
Expand All @@ -14,7 +14,7 @@
<field name="to_invoice" />
<field name="invoiced" />
<field name="invoice_ids" optional="hide" widget="many2many_tags" />
</tree>
</list>
</field>
</record>
<record id="view_purchase_invoice_plan_form" model="ir.ui.view">
Expand Down Expand Up @@ -52,7 +52,6 @@
</div>
</xpath>
<xpath expr="//button[@name='action_create_invoice']" position="before">
<field name="ip_invoice_plan" invisible="1" />
<button
name="%(action_view_purchase_make_planned_invoice)d"
string="Create Bill by Plan"
Expand Down Expand Up @@ -162,7 +161,7 @@
<field name="name">view.purchase.invoice.plan.tree</field>
<field name="model">purchase.invoice.plan</field>
<field name="arch" type="xml">
<tree edit="0" create="0" delete="0">
<list edit="0" create="0" delete="0">
<field name="purchase_id" />
<field name="installment" />
<field name="plan_date" />
Expand All @@ -173,7 +172,7 @@
<field name="to_invoice" />
<field name="invoiced" />
<field name="invoice_ids" widget="many2many_tags" />
</tree>
</list>
</field>
</record>
<record id="action_purchase_invoice_plan" model="ir.actions.act_window">
Expand Down
4 changes: 2 additions & 2 deletions purchase_invoice_plan/wizard/purchase_create_invoice_plan.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import ValidationError


Expand Down Expand Up @@ -31,7 +31,7 @@ class PurchaseCreateInvoicePlan(models.TransientModel):
@api.constrains("num_installment")
def _check_num_installment(self):
if self.num_installment <= 1:
raise ValidationError(_("Number Installment must greater than 1"))
raise ValidationError(self.env._("Number Installment must greater than 1"))

def purchase_create_invoice_plan(self):
purchase = self.env["purchase.order"].browse(self._context.get("active_id"))
Expand Down

0 comments on commit da92227

Please sign in to comment.