Skip to content

Commit

Permalink
[10.0][ADD] sale_order_invoicing_finished_task: New module
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-teruel committed Jun 27, 2017
1 parent 47b6ab7 commit aabe53e
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 0 deletions.
62 changes: 62 additions & 0 deletions sale_order_invoicing_finished_task/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

==================================
Sale Order Invoicing Finished Task
==================================

This module extends sale_service module to allow invoice order lines only if
his task has been finished.

Usage
=====

To use this module, you need to:

#. Go to


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/167/10.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/167/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.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/
blob/master/template/module/static/description/icon.svg>`_.
* Open Clipart: `Icon <https://openclipart.org/detail/260861/warehouse15>`_.


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

* Sergio Teruel <[email protected]>
* Carlos Dauden <[email protected]>

Maintainer
----------

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

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
3 changes: 3 additions & 0 deletions sale_order_invoicing_finished_task/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
23 changes: 23 additions & 0 deletions sale_order_invoicing_finished_task/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Sergio Teruel <[email protected]>
# Copyright 2017 Carlos Dauden <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Sale Order Invoicing Finished Task",
"summary": "Allow invoice order lines if his task has been finished",
"version": "10.0.1.0.0",
"category": "Sales",
"website": "http://www.tecnativa.com",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"sale_timesheet",
],
"data": [
"views/product_view.xml",
],
}
4 changes: 4 additions & 0 deletions sale_order_invoicing_finished_task/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-

from . import product
from . import sale_order
14 changes: 14 additions & 0 deletions sale_order_invoicing_finished_task/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Sergio Teruel <[email protected]>
# Copyright 2017 Carlos Dauden <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = 'product.template'

invoicing_finished_task = fields.Boolean(
help='Invoice the order lines only when the task is in folded stage',
)
45 changes: 45 additions & 0 deletions sale_order_invoicing_finished_task/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Sergio Teruel <[email protected]>
# Copyright 2017 Carlos Dauden <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
import odoo.addons.decimal_precision as dp


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

@api.depends('state', 'order_line.invoice_status',
'order_line.task_ids.stage_id.fold')
def _get_invoiced(self):
super(SaleOrder, self)._get_invoiced()
for order in self.filtered(lambda x: x.picking_policy == 'one'):
if not all(order.tasks_ids.mapped('stage_id.fold')):
order.update({
'invoice_status': 'no',
})


class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'

task_ids = fields.One2many(
comodel_name='project.task',
inverse_name='sale_line_id',
string='Tasks',
)

@api.depends('qty_invoiced', 'qty_delivered', 'product_uom_qty',
'order_id.state', 'task_ids.stage_id.fold')
def _get_to_invoice_qty(self):
lines = self.filtered(
lambda x: x.product_id.type == 'service' and
x.product_id.invoicing_finished_task and
x.product_id.track_service == 'task')
for line in lines:
if all(line.task_ids.mapped('stage_id.fold')):
super(SaleOrderLine, line)._get_to_invoice_qty()
else:
line.qty_to_invoice = 0.0
super(SaleOrderLine, self - lines)._get_to_invoice_qty()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions sale_order_invoicing_finished_task/views/product_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Sergio Teruel <[email protected]>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="view_product_timesheet_form" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id"
ref="sale_timesheet.view_product_timesheet_form"/>
<field name="arch" type="xml">
<field name="project_id" position="before">
<field name="invoicing_finished_task"
attrs="{'invisible':['|', ('type','!=','service'), ('track_service', '!=', 'task')]}"/>
</field>
</field>
</record>

</odoo>

0 comments on commit aabe53e

Please sign in to comment.