Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] sale_order_whole_delivered_invoiceability: Migration to version 17.0 #1877

Open
wants to merge 3 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions sale_order_whole_delivered_invoiceability/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
=========================================
Sale Order Whole Delivered Invoiceability
=========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d41a21754b0e3e1281e8d05a8276d9b5aff794c2e7d2959ce8e04d5e055fa7e5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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/17.0/sale_order_whole_delivered_invoiceability
: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-17-0/account-invoicing-17-0-sale_order_whole_delivered_invoiceability
: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=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module prevents the invoiceability of the sale orders until all the
stockable products has been delivered.

**Table of contents**

.. contents::
:local:

Configuration
=============

1. Create a new storable product
2. Set its invoicing policy as "Delivered Quantities".

Usage
=====

To use this module you need to:

1. Go to a customer that you do not want to invoice for incomplete
deliveries and check the option ‘Whole Delivered Invoiceability’.
2. Create a sales order and do a partial delivery.

Although it is possible to create an invoice from the order itself, the
‘Create invoice’ button will remain white and the order will not appear
in the list of orders to be invoiced, which can be consulted from the
‘To invoice’ menu.

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:%20sale_order_whole_delivered_invoiceability%0Aversion:%2017.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.

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Pedro M. Baeza
- Pilar Vargas

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions sale_order_whole_delivered_invoiceability/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
14 changes: 14 additions & 0 deletions sale_order_whole_delivered_invoiceability/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Sale Order Whole Delivered Invoiceability",
"version": "17.0.1.0.0",
"category": "Sales Management",
"license": "AGPL-3",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
"depends": ["sale"],
"data": ["views/res_partner_view.xml", "views/sale_order_view.xml"],
"installable": True,
}
46 changes: 46 additions & 0 deletions sale_order_whole_delivered_invoiceability/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_whole_delivered_invoiceability
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-03 16:50+0000\n"
"PO-Revision-Date: 2024-09-03 18:54+0200\n"
"Last-Translator: \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: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.0.1\n"

#. module: sale_order_whole_delivered_invoiceability
#: model:ir.model,name:sale_order_whole_delivered_invoiceability.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: sale_order_whole_delivered_invoiceability
#: model_terms:ir.ui.view,arch_db:sale_order_whole_delivered_invoiceability.view_sales_order_filter
msgid "Partial orders not invoiced"
msgstr "Pedidos parciales no facturados"

#. module: sale_order_whole_delivered_invoiceability
#: model:ir.model.fields,help:sale_order_whole_delivered_invoiceability.field_res_partner__whole_delivered_invoiceability
#: model:ir.model.fields,help:sale_order_whole_delivered_invoiceability.field_res_users__whole_delivered_invoiceability
msgid "Prevent invoicing until everything has been delivered."
msgstr "Evitar la facturación hasta que se haya entregado todo."

#. module: sale_order_whole_delivered_invoiceability
#: model:ir.model,name:sale_order_whole_delivered_invoiceability.model_sale_order
msgid "Sales Order"
msgstr "Órdenes de Venta"

#. module: sale_order_whole_delivered_invoiceability
#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_res_partner__whole_delivered_invoiceability
#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_res_users__whole_delivered_invoiceability
#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_sale_order__whole_delivered_invoiceability
msgid "Whole Delivered Invoiceability"
msgstr "Facturación de entregas completas"
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_order_whole_delivered_invoiceability
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_order_whole_delivered_invoiceability
#: model:ir.model,name:sale_order_whole_delivered_invoiceability.model_res_partner
msgid "Contact"
msgstr ""

#. module: sale_order_whole_delivered_invoiceability
#: model_terms:ir.ui.view,arch_db:sale_order_whole_delivered_invoiceability.view_sales_order_filter
msgid "Partial orders not invoiced"
msgstr ""

#. module: sale_order_whole_delivered_invoiceability
#: model:ir.model.fields,help:sale_order_whole_delivered_invoiceability.field_res_partner__whole_delivered_invoiceability
#: model:ir.model.fields,help:sale_order_whole_delivered_invoiceability.field_res_users__whole_delivered_invoiceability
msgid "Prevent invoicing until everything has been delivered."
msgstr ""

#. module: sale_order_whole_delivered_invoiceability
#: model:ir.model,name:sale_order_whole_delivered_invoiceability.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: sale_order_whole_delivered_invoiceability
#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_res_partner__whole_delivered_invoiceability
#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_res_users__whole_delivered_invoiceability
#: model:ir.model.fields,field_description:sale_order_whole_delivered_invoiceability.field_sale_order__whole_delivered_invoiceability
msgid "Whole Delivered Invoiceability"
msgstr ""
3 changes: 3 additions & 0 deletions sale_order_whole_delivered_invoiceability/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import res_partner
from . import sale_order
18 changes: 18 additions & 0 deletions sale_order_whole_delivered_invoiceability/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


class ResPartner(models.Model):
_inherit = "res.partner"

whole_delivered_invoiceability = fields.Boolean(
help="Prevent invoicing until everything has been delivered."
)

@api.model
def _commercial_fields(self):
"""Add this field to commercial fields, as it should be propagated
to children.
"""
return super()._commercial_fields() + ["whole_delivered_invoiceability"]
40 changes: 40 additions & 0 deletions sale_order_whole_delivered_invoiceability/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.tools import float_compare


class SaleOrder(models.Model):
_inherit = "sale.order"

whole_delivered_invoiceability = fields.Boolean(
compute="_compute_whole_delivered_invoiceability",
store=True,
readonly=False,
)

@api.depends("partner_id")
def _compute_whole_delivered_invoiceability(self):
for record in self:
if record.partner_id.whole_delivered_invoiceability:
record.whole_delivered_invoiceability = True

@api.depends("whole_delivered_invoiceability")
def _compute_invoice_status(self):
# Intercept the invoice_status computed method to
# set it as not invoiceable if the delivered quantity
# is less than the ordered quantity.
res = super()._compute_invoice_status()
for order in self.filtered("whole_delivered_invoiceability"):
uncomplete_lines = order.order_line.filtered(
lambda line: line.product_id.invoice_policy == "delivery"
and float_compare(
line.product_uom_qty,
line.qty_delivered,
precision_rounding=line.product_uom.rounding,
)
> 0
)
if uncomplete_lines:
order.invoice_status = "no"
return res
3 changes: 3 additions & 0 deletions sale_order_whole_delivered_invoiceability/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions sale_order_whole_delivered_invoiceability/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. Create a new storable product
2. Set its invoicing policy as "Delivered Quantities".
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Tecnativa](https://www.tecnativa.com):
- Pedro M. Baeza
- Pilar Vargas
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module prevents the invoiceability of the sale orders until all the
stockable products has been delivered.
10 changes: 10 additions & 0 deletions sale_order_whole_delivered_invoiceability/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To use this module you need to:

1. Go to a customer that you do not want to invoice for incomplete
deliveries and check the option ‘Whole Delivered Invoiceability’.
2. Create a sales order and do a partial delivery.

Although it is possible to create an invoice from the order itself, the
‘Create invoice’ button will remain white and the order will not appear
in the list of orders to be invoiced, which can be consulted from the
‘To invoice’ menu.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading