Skip to content

Commit

Permalink
[IMP] sale_order_invoicing_finished_task (OCA#556)
Browse files Browse the repository at this point in the history
When the product has an invoicing policy Ordered Quantity, setting the task
as Invoiceable will set the delivered qty on the sale order line to the ordered quantity.
  • Loading branch information
gurneyalex authored and ivantodorovich committed Apr 21, 2021
1 parent d9b0c23 commit 61a9de3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
4 changes: 4 additions & 0 deletions sale_order_invoicing_finished_task/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ To use this module, you need to:

.. image:: static/description/task_view_invoicefinishedtask.png

If the product is configured with an invoicing policy = Order, then the
delivered quantity is set to the ordered quantity. Otherwise, the time spent
on the task is used.

6. Optional: if you want to use project stages to control this Go To
Project -> Settings -> Stage -> You have to set true the field Invoiceable
in the stages that you consider are invoiceable. Event to use stages for
Expand Down
2 changes: 1 addition & 1 deletion sale_order_invoicing_finished_task/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "Sale Order Invoicing Finished Task",
"summary": "Control invoice order lines if his task has been finished",
"version": "10.0.1.0.1",
"version": "10.0.1.0.2",
"category": "Sales",
"website": "https://github.com/OCA/sale-workflow",
"author": "Tecnativa, "
Expand Down
15 changes: 8 additions & 7 deletions sale_order_invoicing_finished_task/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
#
# Translators:
# OCA Transbot <[email protected]>, 2017
# Quentin THEURET <[email protected]>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-11-23 01:51+0000\n"
"PO-Revision-Date: 2017-11-23 01:51+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"POT-Creation-Date: 2018-02-28 01:48+0000\n"
"PO-Revision-Date: 2018-02-28 01:48+0000\n"
"Last-Translator: Quentin THEURET <odoo@kerpeo.com>, 2018\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -41,7 +42,7 @@ msgstr ""
#. module: sale_order_invoicing_finished_task
#: model:ir.model,name:sale_order_invoicing_finished_task.model_product_template
msgid "Product Template"
msgstr ""
msgstr "Modèle de produit"

#. module: sale_order_invoicing_finished_task
#: model:ir.model,name:sale_order_invoicing_finished_task.model_sale_order
Expand Down Expand Up @@ -69,19 +70,19 @@ msgid "Tasks"
msgstr ""

#. module: sale_order_invoicing_finished_task
#: code:addons/sale_order_invoicing_finished_task/models/project.py:70
#: code:addons/sale_order_invoicing_finished_task/models/project.py:73
#, python-format
msgid "You cannot add a task to and invoiced Sale Order Line"
msgstr ""

#. module: sale_order_invoicing_finished_task
#: code:addons/sale_order_invoicing_finished_task/models/project.py:55
#: code:addons/sale_order_invoicing_finished_task/models/project.py:58
#, python-format
msgid "You cannot modify the Sale Order Line of the task once it is invoiced"
msgstr ""

#. module: sale_order_invoicing_finished_task
#: code:addons/sale_order_invoicing_finished_task/models/project.py:45
#: code:addons/sale_order_invoicing_finished_task/models/project.py:46
#, python-format
msgid ""
"You cannot modify the status if there is no Sale Order Line or if it has "
Expand Down
9 changes: 6 additions & 3 deletions sale_order_invoicing_finished_task/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ def _onchange_stage_id(self):
@api.multi
def toggle_invoiceable(self):
for task in self:
sale_line = task.sale_line_id
# We dont' want to modify when the related SOLine is invoiced
if (not task.sale_line_id or
task.sale_line_id.state in ('done', 'cancel') or
task.sale_line_id.invoice_status in ('invoiced',)):
if (not sale_line or
sale_line.state in ('done', 'cancel') or
sale_line.invoice_status in ('invoiced',)):
raise UserError(_("You cannot modify the status if there is "
"no Sale Order Line or if it has been "
"invoiced."))
task.invoiceable = not task.invoiceable
if sale_line and sale_line.product_id.invoice_policy == 'order':
sale_line.qty_delivered = sale_line.product_uom_qty

@api.multi
def write(self, vals):
Expand Down
17 changes: 17 additions & 0 deletions sale_order_invoicing_finished_task/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,20 @@ def _get_to_invoice_qty(self):
else:
line.qty_to_invoice = 0.0
super(SaleOrderLine, self - lines)._get_to_invoice_qty()

@api.multi
def _compute_analytic(self, domain=None):
if not domain and self.ids:
domain = [
('so_line', 'in', self.ids),
# don't update the qty on sale order lines which are not
# with a product invoiced on ordered qty +
# invoice_finished task = True
'|',
('so_line.product_id.invoice_policy', '!=', 'order'),
('so_line.product_id.invoicing_finished_task', '=', False),
'|',
('amount', '<=', 0.0),
('project_id', '!=', False),
]
return super(SaleOrderLine, self)._compute_analytic(domain=domain)

0 comments on commit 61a9de3

Please sign in to comment.