[IMP] sale_timesheet: add wizard to link multiple task to SO lines

Adding a wizard to assign multiple task to the same
sale order line. This will allow user to invoice
timesheet created before SO confirmation.
This commit is contained in:
jem-odoo
2018-04-06 14:30:46 +02:00
parent 8f3f1827cb
commit 7782265a8a
5 changed files with 69 additions and 0 deletions
+1
View File
@@ -2,5 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import wizard
from . import controllers
from . import report
+1
View File
@@ -27,6 +27,7 @@ have real delivered quantities in sales orders.
'views/hr_timesheet_templates.xml',
'report/project_profitability_report_analysis_views.xml',
'data/sale_timesheet_filters.xml',
'wizard/project_task_assign_so_line_views.xml',
],
'demo': [
'data/sale_service_demo.xml',
+4
View File
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import project_task_assign_so_line
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class ProjectTaskAssignSOLine(models.TransientModel):
_name = 'project.task.assign.sale'
_description = "Assign Sale Order line to tasks"
@api.model
def default_get(self, fields):
result = super(ProjectTaskAssignSOLine, self).default_get(fields)
if self._context.get('active_model') == 'project.task' and 'task_ids' in fields:
result['task_ids'] = self._context.get('active_ids', [])
return result
sale_line_id = fields.Many2one('sale.order.line', 'Sales Order Item', domain=[('is_service', '=', True)], help="Sale order line to link to selected tasks")
partner_id = fields.Many2one('res.partner', related='sale_line_id.order_partner_id', readonly=True)
task_ids = fields.Many2many('project.task', 'project_task_assign_so_line_rel', 'task_id', 'wizard_id', string='Tasks', domain=[('parent_id', '=', False)], help="Select the tasks to assign to the Sale Order Items. You can only choose task (no sub tasks).")
@api.multi
def action_assign_sale_line(self):
for wizard in self:
wizard.task_ids.write({
'sale_line_id': wizard.sale_line_id.id,
'partner_id': wizard.partner_id.id,
})
return {'type': 'ir.actions.act_window_close'}
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="project_task_assign_so_line_view_form" model="ir.ui.view">
<field name="name">project.task.assign.sale.wizard.form</field>
<field name="model">project.task.assign.sale</field>
<field name="arch" type="xml">
<form string="Assign sale line to Tasks">
<group>
<field name="task_ids" widget="many2many_tags"/>
<field name="sale_line_id" options="{'no_create_edit': True}" context="{'sale_show_order_product_name': True}"/>
<field name="partner_id"/>
</group>
<footer>
<button string="Assign" type="object" name="action_assign_sale_line" class="oe_highlight"/>
<button string="Cancel" special="cancel" type="object" class="btn btn-default oe_inline"/>
</footer>
</form>
</field>
</record>
<record id="project_task_action_multi_assign_so_line" model="ir.actions.act_window">
<field name="name">Assign Sale Order Item</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">project.task.assign.sale</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="project_task_assign_so_line_view_form"/>
<field name="target">new</field>
<field name="multi">True</field>
<field name="binding_model_id" ref="project.model_project_task"/>
</record>
</odoo>