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 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
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
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)