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

[IMP] sale_order_invoicing_finished_task #556

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
3 changes: 3 additions & 0 deletions sale_order_invoicing_finished_task/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def toggle_invoiceable(self):
"no Sale Order Line or if it has been "
"invoiced."))
task.invoiceable = not task.invoiceable
if task.sale_line_id and task.sale_line_id.product_id.invoice_policy == 'order':
task.sale_line_id.qty_delivered = task.sale_line_id.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)