-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sale_project_fixed_price_task_completed_invoicing
- Loading branch information
Showing
7 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
sale_project_fixed_price_task_completed_invoicing/__init__.py
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 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models |
20 changes: 20 additions & 0 deletions
20
sale_project_fixed_price_task_completed_invoicing/__manifest__.py
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,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Sale project fixed price task completed invoicing", | ||
"version": "10.0.1.0.0", | ||
"depends": [ | ||
'sale', | ||
'product', | ||
'project', | ||
], | ||
"author": "Camptocamp,Odoo Community Association (OCA)", | ||
"website": "http://www.camptocamp.com", | ||
"license": "AGPL-3", | ||
"category": "Sale", | ||
"data": [ | ||
'views/project_views.xml', | ||
], | ||
'installable': True, | ||
} |
6 changes: 6 additions & 0 deletions
6
sale_project_fixed_price_task_completed_invoicing/models/__init__.py
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,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import product_template | ||
from . import project_task | ||
from . import sale_order_line |
13 changes: 13 additions & 0 deletions
13
sale_project_fixed_price_task_completed_invoicing/models/product_template.py
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,13 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = 'product.template' | ||
|
||
track_service = fields.Selection(selection_add=[ | ||
('completed_task', 'Completed Task')] | ||
) |
43 changes: 43 additions & 0 deletions
43
sale_project_fixed_price_task_completed_invoicing/models/project_task.py
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,43 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class ProjectTask(models.Model): | ||
_inherit = 'project.task' | ||
|
||
invoiceable = fields.Boolean( | ||
string='Invoiceable', | ||
) | ||
fixed_price = fields.Boolean( | ||
string='Fixed Price', | ||
) | ||
|
||
@api.multi | ||
def toggle_invoiceable(self): | ||
for task in self: | ||
# 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'): | ||
continue | ||
task.invoiceable = not task.invoiceable | ||
|
||
@api.multi | ||
def write(self, vals): | ||
for task in self: | ||
if (vals.get('sale_line_id') and | ||
task.sale_line_id.state in ('done')): | ||
raise ValidationError(_('You cannot modify the Sale Order ' | ||
'Line of the task once it is invoiced') | ||
) | ||
|
||
def create(self, vals): | ||
SOLine = self.env['sale.order.line'] | ||
|
||
so_line = SOLine.browse(vals.get('sale_line_id')) | ||
if so_line.state in ('done'): | ||
raise ValidationError(_('You cannot add a task to and invoiced ' | ||
'Sale Order Line')) | ||
return super(ProjectTask, self).create(vals) |
19 changes: 19 additions & 0 deletions
19
sale_project_fixed_price_task_completed_invoicing/models/sale_order_line.py
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,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = 'sale.order.line' | ||
|
||
@api.constrains('product_id') | ||
def _onchange_product_id(self): | ||
for line in self: | ||
if ('track_service' == line.product_id.track_service and | ||
line.product_uom_qty != 1.0): | ||
raise ValidationError('Error! You cannot have more than one ' | ||
'"track_service" sold in one Sale Order ' | ||
'Line') |
24 changes: 24 additions & 0 deletions
24
sale_project_fixed_price_task_completed_invoicing/views/project_views.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,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="edit_project_task_track" model="ir.ui.view"> | ||
<field name="name">project.task.form.track</field> | ||
<field name="model">project.task</field> | ||
<field name="inherit_id" ref="project.view_task_form2"/> | ||
<field name="arch" type="xml"> | ||
|
||
<xpath expr="//field[@name='planned_hours']" position="after"> | ||
<field name='invoiceable'/> | ||
<field name="fixed_price"/> | ||
</xpath> | ||
|
||
<div name="button_box" position="inside"> | ||
<button class="oe_stat_button" name="toggle_invoiceable" type="object" icon="fa-file" attrs="{'invisible': [('fixed_price', '=', False)]}"> | ||
<p>Invoiceable</p> | ||
</button> | ||
</div> | ||
|
||
</field> | ||
</record> | ||
|
||
</odoo> |