diff --git a/sale_invoice_plan/README.rst b/sale_invoice_plan/README.rst index fa41d1de469..cc1419dd364 100644 --- a/sale_invoice_plan/README.rst +++ b/sale_invoice_plan/README.rst @@ -2,10 +2,13 @@ Sales Invoice Plan ================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e65d2ca5ee4ad4e5e68e2d61d67b087fa84c66d97eb1c690d2c08ce8b36f4b23 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png :target: https://odoo-community.org/page/development-status @@ -14,16 +17,16 @@ Sales 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%2Fsale--workflow-lightgray.png?logo=github - :target: https://github.com/OCA/sale-workflow/tree/15.0/sale_invoice_plan + :target: https://github.com/OCA/sale-workflow/tree/16.0/sale_invoice_plan :alt: OCA/sale-workflow .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/sale-workflow-15-0/sale-workflow-15-0-sale_invoice_plan + :target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_invoice_plan :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/167/15.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/sale-workflow&target_branch=16.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| By standard feature, user can gradually create partial invoices, one by one. This module add ability to create invoices based on the predefined invoice plan, @@ -76,8 +79,8 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -123,6 +126,6 @@ Current `maintainer `__: |maintainer-kittiu| -This module is part of the `OCA/sale-workflow `_ project on GitHub. +This module is part of the `OCA/sale-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_invoice_plan/__manifest__.py b/sale_invoice_plan/__manifest__.py index 33077c15c67..38947e2ec10 100644 --- a/sale_invoice_plan/__manifest__.py +++ b/sale_invoice_plan/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Sales Invoice Plan", "summary": "Add to sales order, ability to manage future invoice plan", - "version": "15.0.1.3.2", + "version": "16.0.1.0.0", "author": "Ecosoft,Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/sale-workflow", diff --git a/sale_invoice_plan/models/sale.py b/sale_invoice_plan/models/sale.py index dc9b32c8e8b..b9148935a76 100644 --- a/sale_invoice_plan/models/sale.py +++ b/sale_invoice_plan/models/sale.py @@ -45,14 +45,14 @@ def _compute_invoice_plan_process(self): for rec in self: has_invoice_plan = rec.use_invoice_plan and rec.invoice_plan_ids to_invoice = rec.invoice_plan_ids.filtered(lambda l: not l.invoiced) + invoice_plan_process = False if rec.state == "sale" and has_invoice_plan and to_invoice: - if rec.invoice_status == "to invoice" or ( - rec.invoice_status == "no" - and "advance" in to_invoice.mapped("invoice_type") - ): - rec.invoice_plan_process = True - continue - rec.invoice_plan_process = False + if rec.invoice_status in [ + "to invoice", + "no", + ] and "advance" in to_invoice.mapped("invoice_type"): + invoice_plan_process = True + rec.invoice_plan_process = invoice_plan_process @api.constrains("invoice_plan_ids") def _check_invoice_plan_total_percent(self): @@ -135,12 +135,13 @@ def _next_date(self, installment_date, interval, interval_type): def _create_invoices(self, grouped=False, final=False, date=None): moves = super()._create_invoices(grouped=grouped, final=final, date=date) - invoice_plan_id = self._context.get("invoice_plan_id") - if invoice_plan_id: - plan = self.env["sale.invoice.plan"].browse(invoice_plan_id) + if self.use_invoice_plan: + plan = self.env["sale.invoice.plan"].search( + [("sale_id", "=", self.id)], limit=1 + ) for move in moves: plan._compute_new_invoice_quantity(move) move.invoice_date = plan.plan_date - move._onchange_invoice_date() + move._compute_date() plan.invoice_move_ids += moves return moves diff --git a/sale_invoice_plan/models/sale_invoice_plan.py b/sale_invoice_plan/models/sale_invoice_plan.py index 3ff4100ebd5..b61496d3023 100644 --- a/sale_invoice_plan/models/sale_invoice_plan.py +++ b/sale_invoice_plan/models/sale_invoice_plan.py @@ -171,15 +171,16 @@ def _compute_last(self): rec.last = rec.installment == last def _compute_new_invoice_quantity(self, invoice_move): - self.ensure_one() - if self.last: # For last install, let the system do the calc. - return - percent = self.percent - move = invoice_move.with_context(check_move_validity=False) - for line in move.invoice_line_ids: - self._update_new_quantity(line, percent) - move.line_ids.filtered("exclude_from_invoice_tab").unlink() - move._move_autocomplete_invoice_lines_values() # recompute dr/cr + for plan in self: + if plan.last: # For last install, let the system do the calc. + return + move = invoice_move.with_context(check_move_validity=False) + for line in move.invoice_line_ids: + plan._update_new_quantity(line, plan.percent) + move.line_ids.filtered( + lambda x: x.display_type + not in ("product", "line_section", "line_note", "payment_term", "tax") + ).unlink() def _update_new_quantity(self, line, percent): """Hook function""" diff --git a/sale_invoice_plan/static/description/index.html b/sale_invoice_plan/static/description/index.html index 468457d6abe..31b88c87959 100644 --- a/sale_invoice_plan/static/description/index.html +++ b/sale_invoice_plan/static/description/index.html @@ -1,20 +1,20 @@ - + - + Sales Invoice Plan