-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[10.0][ADD] sale_order_invoicing_finished_task: New module
- Loading branch information
1 parent
47b6ab7
commit 1856f11
Showing
9 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.. 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>`_. | ||
|
||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import product | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
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.
9 changes: 9 additions & 0 deletions
9
sale_order_invoicing_finished_task/static/description/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |