Skip to content

Commit

Permalink
Merge PR #1681 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by StefanRijnhart
  • Loading branch information
OCA-git-bot committed Feb 17, 2023
2 parents b2f0f4b + cd35dfd commit 12fac69
Show file tree
Hide file tree
Showing 19 changed files with 873 additions and 0 deletions.
96 changes: 96 additions & 0 deletions purchase_force_invoiced/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
=======================
Purchase Force Invoiced
=======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/15.0/purchase_force_invoiced
: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-15-0/purchase-workflow-15-0-purchase_force_invoiced
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/142/15.0
:alt: Try me on Runbot

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

This module adds the possibility for users to force the invoice status of the
purchase orders to 'No Bill to Receive', even when not all the
quantities, ordered or delivered, have been invoiced.

This feature is useful in the following scenario:

* The supplier disputes the quantities to be billed for, after the
products have been delivered to her/him, and you agree to reduce the
quantity to invoice (without expecting a refund).

* When migrating from a previous Odoo version, in some cases there is less
quantity billed to what was delivered, and you don't want these old purchase
orders to appear in your 'Waiting Bills' list.

**Table of contents**

.. contents::
:local:

Usage
=====

#. Create a purchase order and confirm it.
#. Receive the products/services.
#. Create a vendor bill and reduce the invoiced quantity. The purchase order
invoicing status is 'Waiting Bills'.
#. Lock the Purchase Order and change its status to 'Done'.
#. Check the field 'Force Invoiced'.

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_force_invoiced%0Aversion:%2015.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
~~~~~~~

* Forgeflow

Contributors
~~~~~~~~~~~~

* Jordi Ballester <[email protected]>
* Rattapong Chokmasermkul <[email protected]>

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/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/15.0/purchase_force_invoiced>`_ project on GitHub.

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

from . import model
from . import reports
17 changes: 17 additions & 0 deletions purchase_force_invoiced/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2019 ForgeFlow S.L.
# Copyright 2019 Aleph Objects, Inc.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

{
"name": "Purchase Force Invoiced",
"summary": "Allows to force the billing status of the purchase order to "
'"Invoiced"',
"version": "16.0.1.0.0",
"author": "Forgeflow, Odoo Community Association (OCA)",
"category": "Purchase Management",
"license": "AGPL-3",
"website": "https://github.com/OCA/purchase-workflow",
"depends": ["purchase"],
"data": ["view/purchase_order.xml"],
"installable": True,
}
37 changes: 37 additions & 0 deletions purchase_force_invoiced/i18n/purchase_force_invoiced.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_force_invoiced
#
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: purchase_force_invoiced
#: model:ir.model.fields,field_description:purchase_force_invoiced.field_purchase_order__force_invoiced
msgid "Force Invoiced"
msgstr ""

#. module: purchase_force_invoiced
#: model:ir.model,name:purchase_force_invoiced.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: purchase_force_invoiced
#: model:ir.model,name:purchase_force_invoiced.model_purchase_report
msgid "Purchase Report"
msgstr ""

#. module: purchase_force_invoiced
#: model:ir.model.fields,help:purchase_force_invoiced.field_purchase_order__force_invoiced
msgid ""
"When you set this field, the purchase order will be considered as fully "
"billed, even when there may be ordered or delivered quantities pending to "
"bill. To use this field, the order must be in 'Locked' state"
msgstr ""
53 changes: 53 additions & 0 deletions purchase_force_invoiced/i18n/zh_CN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_force_invoiced
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-09-02 14:40+0000\n"
"Last-Translator: 黎伟杰 <[email protected]>\n"
"Language-Team: none\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 3.8\n"

#. module: purchase_force_invoiced
#: model:ir.model.fields,field_description:purchase_force_invoiced.field_purchase_order__force_invoiced
msgid "Force Invoiced"
msgstr ""

#. module: purchase_force_invoiced
#: model:ir.model,name:purchase_force_invoiced.model_purchase_order
msgid "Purchase Order"
msgstr "采购订单"

#. module: purchase_force_invoiced
#: model:ir.model,name:purchase_force_invoiced.model_purchase_report
msgid "Purchase Report"
msgstr ""

#. module: purchase_force_invoiced
#: model:ir.model.fields,help:purchase_force_invoiced.field_purchase_order__force_invoiced
msgid ""
"When you set this field, the purchase order will be considered as fully "
"billed, even when there may be ordered or delivered quantities pending to "
"bill. To use this field, the order must be in 'Locked' state"
msgstr ""

#~ msgid "Force invoiced"
#~ msgstr "强制开具发票"

#~ msgid ""
#~ "When you set this field, the purchase order will be considered as fully "
#~ "billed, even when there may be ordered or delivered quantities pending to "
#~ "bill."
#~ msgstr ""
#~ "设置此字段时,即使订单或已交付的数量待处理,也会将采购订单视为已完成开票。"

#~ msgid "Invoice"
#~ msgstr "发票"
3 changes: 3 additions & 0 deletions purchase_force_invoiced/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from . import purchase_order
27 changes: 27 additions & 0 deletions purchase_force_invoiced/model/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

force_invoiced = fields.Boolean(
readonly=True,
states={"done": [("readonly", False)]},
copy=False,
tracking=True,
help="When you set this field, the purchase order will be "
"considered as fully billed, even when there may be ordered "
"or delivered quantities pending to bill. To use this field, "
"the order must be in 'Locked' state",
)

@api.depends("force_invoiced")
def _get_invoiced(self):
res = super()._get_invoiced()
for order in self.filtered(
lambda po: po.force_invoiced and po.invoice_status == "to invoice"
):
order.invoice_status = "invoiced"
return res
2 changes: 2 additions & 0 deletions purchase_force_invoiced/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Jordi Ballester <[email protected]>
* Rattapong Chokmasermkul <[email protected]>
13 changes: 13 additions & 0 deletions purchase_force_invoiced/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This module adds the possibility for users to force the invoice status of the
purchase orders to 'No Bill to Receive', even when not all the
quantities, ordered or delivered, have been invoiced.

This feature is useful in the following scenario:

* The supplier disputes the quantities to be billed for, after the
products have been delivered to her/him, and you agree to reduce the
quantity to invoice (without expecting a refund).

* When migrating from a previous Odoo version, in some cases there is less
quantity billed to what was delivered, and you don't want these old purchase
orders to appear in your 'Waiting Bills' list.
6 changes: 6 additions & 0 deletions purchase_force_invoiced/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#. Create a purchase order and confirm it.
#. Receive the products/services.
#. Create a vendor bill and reduce the invoiced quantity. The purchase order
invoicing status is 'Waiting Bills'.
#. Lock the Purchase Order and change its status to 'Done'.
#. Check the field 'Force Invoiced'.
3 changes: 3 additions & 0 deletions purchase_force_invoiced/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from . import purchase_report
21 changes: 21 additions & 0 deletions purchase_force_invoiced/reports/purchase_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
# Copyright 2022 Tecnativa - Pedro M. Baeza

from odoo import models


class PurchaseReport(models.Model):
_inherit = "purchase.report"

def _select(self):
"""Put quantity to be billed as 0 if it has been forced."""
select_str = super()._select()
select_str = select_str.replace(
"case when t.purchase_method = 'purchase'",
"case when po.force_invoiced then 0.0 "
"else (case when t.purchase_method = 'purchase' ",
)
select_str = select_str.replace(
"end as qty_to_be_billed", "end) end as qty_to_be_billed"
)
return select_str
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 12fac69

Please sign in to comment.