浏览代码

commit inicial

Rodney Elpidio Enciso Arias 7 年之前
当前提交
0bef76c3c9

+ 23 - 0
__init__.py

@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Cybrosys Technologies Pvt. Ltd.
+#    Copyright (C) 2008-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
+#    Author: Nilmar Shereef(<http://www.cybrosys.com>)
+#    you can modify it under the terms of the GNU LESSER
+#    GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
+#
+#    It is forbidden to publish, distribute, sublicense, or sell copies
+#    of the Software or modified copies of the Software.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
+#
+#    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
+#    GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
+#    If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import models

二进制
__init__.pyc


+ 28 - 0
__openerp__.py

@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+{
+    'name': 'Eiru Base for Services',
+    'version': '1.0',
+    'summary': 'Base for services Operations',
+    'description': 'Vehicle workshop operations & Its reports',
+    'category': 'Industries',
+    'author': 'Cybrosys Techno Solutions - Eiru',
+    'company': 'Cybrosys Techno Solutions - Eiru',
+    'website': "http://www.eiru.com.py",
+    'depends': ['base',
+                'account_accountant'],
+    'data': [
+        'views/project_service.xml',
+        'views/project_service_task.xml',
+        'views/project_service_activity.xml',
+        'views/project_service_material.xml',
+        'views/project_service_stage.xml',
+        'views/product_service.xml',
+        'views/product_service_brand.xml',
+        'views/template.xml',
+        'security/ir.model.access.csv',
+    ],
+    'license': 'AGPL-3',
+    'installable': True,
+    'auto_install': False,
+    'application': True,
+}

+ 10 - 0
models/__init__.py

@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+import project_service
+import project_service_task
+import project_service_activity
+import project_service_material
+import project_service_stage
+# import project_service_tag
+import product_service
+import product_service_brand
+import account_invoice

二进制
models/__init__.pyc


+ 8 - 0
models/account_invoice.py

@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+from openerp import models, fields, api
+from openerp.exceptions import except_orm, Warning, RedirectWarning
+
+class AccountInvoice(models.Model):
+    _inherit = 'account.invoice'
+
+    task_invoice_id = fields.Many2one('project.service.task')

二进制
models/account_invoice.pyc


+ 36 - 0
models/product_service.py

@@ -0,0 +1,36 @@
+# -*- encoding: utf-8 -*-
+from openerp import models, fields, api, tools
+from openerp.exceptions import ValidationError
+
+class ProductService(models.Model):
+    _name = 'product.service'
+
+    name=fields.Char('Nombre', compute='_get_product_name', store=True)
+    model=fields.Char('Modelo')
+    year=fields.Integer('Año')
+    number=fields.Char('Número')
+    logo = fields.Binary('Logo File')
+    partner_id = fields.Many2one(
+        'res.partner',
+        string='Cliente',
+        ondelete='restrict'
+    )
+    description = fields.Text('Description', translate=True)
+    valuation = fields.Float('Valor')
+    product_service_brand_id = fields.Many2one(
+        'product.service.brand',
+        string='Marca'
+    )
+
+    @api.one
+    @api.constrains('number')
+    def _controla_numero(self):
+        part_obj = self.env['product.service'].search([('number','=',self.number)])
+        if len(part_obj) > 1:
+            raise ValidationError('La numero debe ser unico')
+
+    @api.one
+    @api.depends('product_service_brand_id','model','number')
+    def _get_product_name(self):
+        self.name = self.product_service_brand_id.name + ' / ' +  self.model + ' / ' + self.number
+

二进制
models/product_service.pyc


+ 23 - 0
models/product_service_brand.py

@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+from openerp import models, fields, api, tools
+from openerp.exceptions import ValidationError
+
+class ProductServiceBrand(models.Model):
+    _name = 'product.service.brand'
+
+    name = fields.Char('Brand Name', required=True)
+    description = fields.Text('Description', translate=True)
+    logo = fields.Binary('Logo File')
+    product_service_ids = fields.One2many(
+        'product.service',
+        'product_service_brand_id',
+    )
+    product_service_count = fields.Integer(
+        string='Numero de autos',
+        compute='_get_product_service_count',
+    )
+
+    @api.one
+    @api.depends('product_service_ids')
+    def _get_product_service_count(self):
+        self.product_service_count = len(self.product_service_ids)

二进制
models/product_service_brand.pyc


+ 62 - 0
models/project_service.py

@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+from openerp import models, fields, api, tools
+from openerp.exceptions import ValidationError, except_orm, Warning, RedirectWarning
+
+class ProjectService(models.Model):
+    _name = 'project.service'
+
+    name = fields.Many2one('product.service','Nombre', required=True) 
+    date_start = fields.Date(string='Start Date')
+    date_due = fields.Date(string='Expiration Date')
+    sequence = fields.Integer(string='Sequence')
+    partner_id =  fields.Many2one('res.partner', 'Customer')
+    image_medium = fields.Binary('Binary File', related="name.logo")
+    state = fields.Selection([('draft', 'Nuevo'),('open', 'En progreso'),
+        ('cancelled', 'Cancelado'),
+        ('pending', 'Pendiente'),
+        ('close', 'Cerrado')],
+        string='Status')
+    color = fields.Integer('Color Index')
+    project_service_task_ids = fields.One2many(
+        'project.service.task',
+        'project_id',
+    )
+    project_service_task_count = fields.Integer(
+        string='Contador de tareas',
+        compute='_get_project_service_task_count',
+    )
+    date_in = fields.Date('Fecha de entrada', default=fields.Date.today())
+    date_out = fields.Date('Fecha de Salida')
+
+    _defaults = {
+        'state': 'open',
+    }
+
+    @api.multi
+    def unlink(self):
+        for project in self:
+            if project.state in ('close'):
+                raise Warning('No puedes borrar un proyecto en estado cerrado')
+            if len(project.project_service_task_ids) > 0:
+                raise Warning('No puedes borrar un proyecto que tiene tareas')
+        return super(ProjectService, self).unlink()
+
+    def on_change_product(self):
+        if not self.name:
+            return {}
+        model = self.pool.get('product.service').browse(self.name)
+        return {
+            'value': {
+                'image_medium': model.logo,
+            }
+        }
+
+    @api.one
+    @api.depends('project_service_task_ids')
+    def _get_project_service_task_count(self):
+        self.project_service_task_count = len(self.project_service_task_ids)
+
+    @api.one 
+    @api.onchange('name')
+    def onchange_name(self):
+        self.partner_id = self.name.partner_id.id

二进制
models/project_service.pyc


+ 29 - 0
models/project_service_activity.py

@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from openerp import fields, models, api
+
+class ProjectServiceActivity(models.Model):
+    _name = 'project.service.activity'
+
+    name=fields.Char('Nombre', compute='_get_product_name', store=True)
+    product_id = fields.Many2one('product.product', string='Planned work', domain=[('type', '=', 'service'),('sale_ok','=',True)])
+    time_spent = fields.Float(string='Estimated Time')
+    work_date = fields.Datetime(string='Date')
+    user_id = fields.Many2one('res.users', string='Responsible')
+    task_id = fields.Many2one('project.service.task', string="Work id")
+    work_cost = fields.Float(string="Service Cost")
+    duration = fields.Float(string='Duration')
+    completed = fields.Boolean(string="Completed")
+
+    _defaults = {
+        'user_id': lambda obj, cr, uid, ctx=None: uid,
+        'work_date': fields.datetime.now(),
+    }
+
+    @api.onchange('product_id')
+    def get_price(self):
+        self.work_cost = self.product_id.lst_price
+
+    api.one
+    @api.depends('task_id','product_id')
+    def _get_product_name(self):
+        self.name = self.task_id.name + ' / ' +  self.product_id.name

二进制
models/project_service_activity.pyc


+ 14 - 0
models/project_service_material.py

@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+from openerp import fields, models, api
+
+class ProjectServiceMaterial(models.Model):
+    _name = 'project.service.material'
+
+    product_id = fields.Many2one('product.product', string='Productos', domain=[('sale_ok','=',True)])
+    amount = fields.Integer(string='Cantidad', default=1)
+    price = fields.Float(string='Precio Unitario')
+    task_id = fields.Many2one(string='project.service.task')
+
+    @api.onchange('product_id')
+    def get_price(self):
+        self.price = self.product_id.lst_price

二进制
models/project_service_material.pyc


+ 15 - 0
models/project_service_stage.py

@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+from openerp import fields, models, api
+from openerp.tools.translate import _
+
+class ProjectServiceStage(models.Model):
+    _name = 'project.service.stage'
+    _order = 'sequence'
+
+    name = fields.Char(string='Stage Name', required=True)
+    description = fields.Text(string='Description', translate=True)
+    sequence = fields.Integer(string='Sequence')
+    fold = fields.Boolean('Folded in Tasks Pipeline', help='This stage is folded in the kanban view when'
+                                'there are no records in that stage to display.')
+
+    _order = 'sequence'

二进制
models/project_service_stage.pyc


二进制
models/project_service_tag.pyc


+ 183 - 0
models/project_service_task.py

@@ -0,0 +1,183 @@
+# -*- coding: utf-8 -*-
+from datetime import date
+from dateutil.relativedelta import relativedelta
+from openerp import models, api, fields, tools, _
+from openerp.exceptions import ValidationError, except_orm, Warning, RedirectWarning
+from openerp.osv import osv
+
+class ProjectServiceTask(models.Model):
+    _name = 'project.service.task'
+
+    name = fields.Char(string='Title', required=True)
+    project_id = fields.Many2one('project.service', string='Vehicle', required=True, track_visibility='onchange')
+    user_id = fields.Many2one('res.users', string='Assigned to', select=True)
+    description = fields.Html('Description')
+    priority = fields.Selection([('0', 'Normal'), ('1', 'High')], string='Priority', select=True)
+    partner_id = fields.Many2one('res.partner', string='Customer')
+    date_assign = fields.Datetime(string='Assigning Date', select=True, copy=False, readonly=True)
+    date_deadline = fields.Datetime(string='Deadline', select=True, copy=False)
+    color = fields.Integer(string='Color Index')
+    stage_id = fields.Many2one('project.service.stage', string='Stage', track_visibility='onchange', copy=False)
+    effective_hour = fields.Float(string='Hours Spent', compute="hours_spent",readonly=True)
+    activity_ids = fields.One2many('project.service.activity', 'task_id', string='Planned/Ordered Works')
+    materials_used = fields.One2many('project.service.material', 'task_id', string='Materials Used')
+    amount_total = fields.Float(string='Total Amount', compute="get_amount_total", readonly=True)
+    include_materials = fields.Boolean('Incluir')
+    state = fields.Selection([
+        ('Preparado', 'Preparado'),
+        ('Facturado', 'Facturado'),
+        ('Cancelado', 'Cancelado'),
+    ], string='Status', readonly=True, default='Preparado', track_visibility='onchange', select=True)
+    sequence = fields.Integer(string='Sequence', select=True, help="Gives the sequence order when displaying a list of tasks.")
+    invoice_ids = fields.One2many('account.invoice', 'task_invoice_id')
+    invoice_count = fields.Integer(
+        string='Facturas',
+        compute='_get_invoice_count', 
+    )
+    works_done = fields.One2many('project.service.activity', 'task_id', string='Work Done', domain=[('completed', '=', True)])
+    _defaults = {
+        'stage_id': 1,
+        'state': 'Preparado',
+        'user_id': lambda obj, cr, uid, ctx=None: uid,
+        'date_start': fields.datetime.now(),
+    }
+
+    @api.one 
+    @api.onchange('project_id')
+    def onchange_name(self):
+        self.partner_id = self.project_id.partner_id.id
+
+    @api.multi
+    def cancel(self):
+        self.state = 'Cancelado'
+
+    @api.depends('activity_ids.work_cost', 'materials_used.price')
+    def get_amount_total(self):
+        for records in self:
+            for hour in records:
+                amount_totall = 0.0
+                for line in hour.activity_ids:
+                    amount_totall += line.work_cost
+                if self.include_materials==True:
+                    for line2 in hour.materials_used:
+                        amount_totall += line2.price
+                records.amount_total = amount_totall
+
+    @api.depends('activity_ids.time_spent')
+    def hours_spent(self):
+        for hour in self:
+            effective_hour = 0.0
+            for line in hour.works_done:
+                effective_hour += line.time_spent
+            self.effective_hour = effective_hour
+
+    @api.one
+    @api.depends('invoice_ids','state')
+    def _get_invoice_count(self):
+        self.invoice_count = len(self.invoice_ids)
+
+    @api.multi
+    def button_draft(self):
+        if self.invoice_count > 0:
+            raise Warning('Esta tarea tiene una factura asociada')
+        if self.invoice_count == 0:
+            for work in self:
+                work.write({'state': 'Preparado'})
+            return True
+
+    @api.multi
+    def unlink(self):
+        for task in self:
+            if task.state in ('Facturado'):
+                raise Warning(('No puedes borrar una tarea ya facturada'))
+            if len(task.activity_ids)>0:
+                raise Warning(('No puedes borrar una tarea que tiene actividades'))
+        return super(ProjectServiceTask, self).unlink()
+
+    @api.multi
+    def Facturado(self):
+        activity = self.activity_ids
+        if not activity:
+            raise osv.except_osv(_('UserError!'), _('No puedes facturas una tarea sin actividades.'))
+        self.state = 'Facturado'
+        inv_obj = self.env['account.invoice']
+        inv_line_obj = self.env['account.invoice.line']
+        customer = self.partner_id
+        if not customer.name:
+            raise osv.except_osv(_('UserError!'), _('Please select a Customer.'))
+        company_id = self.env['res.users'].browse(1).company_id
+        self.ensure_one()
+        ir_values = self.env['ir.values']
+        inv_data = {
+            'name': customer.name,
+            'reference': customer.name,
+            'account_id': customer.property_account_receivable.id,
+            'partner_id': customer.id,
+            'origin': self.name,
+            'task_invoice_id': self.id 
+        }
+        inv_id = inv_obj.create(inv_data)
+        for records in self.activity_ids:
+            if records.product_id.id:
+                income_account = records.product_id.categ_id.property_account_income_categ.id
+            if not income_account:
+                raise osv.except_osv(_('UserError!'), _('There is no income account defined '
+                                                        'for this product: "%s".') % (records.product_id.name,))
+            if records.completed == False:
+                raise osv.except_osv(_('UserError!'), _('Esta actividad aun no ha sido concluida '
+                                                        '"%s".') % (records.product_id.name,))
+
+            inv_line_data = {
+                'name': records.product_id.name,
+                'account_id': income_account,
+                'price_unit': records.work_cost,
+                'quantity': 1,
+                'product_id': records.product_id.id,
+                'invoice_id': inv_id.id,
+            }
+            inv_line_obj.create(inv_line_data)
+        for records in self.materials_used:
+            if records.product_id.id:
+                income_account = records.product_id.categ_id.property_account_income_categ.id
+            if not income_account:
+                raise osv.except_osv(_('UserError!'), _('There is no income account defined '
+                                                        'for this product: "%s".') % (records.product_id.name,))
+            if self.include_materials==True:
+                inv_line_data = {
+                    'name': records.product_id.name,
+                    'account_id': income_account,
+                    'price_unit': records.price,
+                    'quantity': records.amount,
+                    'product_id': records.product_id.id,
+                    'invoice_id': inv_id.id,
+                }
+                inv_line_obj.create(inv_line_data)
+        imd = self.env['ir.model.data']
+        action = imd.xmlid_to_object('account.action_invoice_tree1')
+        list_view_id = imd.xmlid_to_res_id('account.invoice_tree')
+        form_view_id = imd.xmlid_to_res_id('account.invoice_form')
+        result = {
+            'name': action.name,
+            'help': action.help,
+            'type': 'ir.actions.act_window',
+            'views': [[list_view_id, 'tree'], [form_view_id, 'form'], [False, 'graph'], [False, 'kanban'],
+                      [False, 'calendar'], [False, 'pivot']],
+            'target': action.target,
+            'context': action.context,
+            'res_model': 'account.invoice',
+        }
+        if len(inv_id) > 1:
+            result['domain'] = "[('id','in',%s)]" % inv_id.ids
+        elif len(inv_id) == 1:
+            result['views'] = [(form_view_id, 'form')]
+            result['res_id'] = inv_id.ids[0]
+        else:
+            result = {'type': 'ir.actions.act_window_close'}
+        invoiced_records = self.env['project.service.task']
+        total = 0
+        for rows in invoiced_records:
+            invoiced_date = rows.date
+            invoiced_date = invoiced_date[0:10]
+            if invoiced_date == str(date.today()):
+                total = total + rows.price_subtotal
+        return result

二进制
models/project_service_task.pyc


+ 21 - 0
security/ir.model.access.csv

@@ -0,0 +1,21 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_project_service","project.service","model_project_service","base.group_partner_manager",1,1,1,1
+"access_project_service_public","project.service.public","model_project_service",,1,0,0,0
+
+"access_project_service_task","project.service.task","model_project_service_task","base.group_partner_manager",1,1,1,1
+"access_project_service_task_public","project.service.task.public","model_project_service_task",,1,0,0,0
+
+"access_project_service_activity","project.service.activity","model_project_service_activity","base.group_partner_manager",1,1,1,1
+"access_project_service_activity_public","project.service.activity.public","model_project_service_activity",,1,0,0,0
+
+"access_project_service_material","project.service.material","model_project_service_material","base.group_partner_manager",1,1,1,1
+"access_project_service_material_public","project.service.material.public","model_project_service_material",,1,0,0,0
+
+"access_project_service_stage","project.service.stage","model_project_service_stage","base.group_partner_manager",1,1,1,1
+"access_project_service_stage_public","project.service.stage.public","model_project_service_stage",,1,0,0,0
+
+"access_product_service","product.service","model_product_service","base.group_partner_manager",1,1,1,1
+"access_product_service_public","product.service.public","model_product_service",,1,0,0,0
+
+"access_product_service_brand","product.service.brand","model_product_service_brand","base.group_partner_manager",1,1,1,1
+"access_product_service_brand_public","product.service.brand.public","model_product_service_brand",,1,0,0,0

+ 10 - 0
static/src/css/vehicles.css

@@ -0,0 +1,10 @@
+.project-card{
+    width: 250px;
+    height: 250px;
+}
+.card-image-box{
+    height: 191px;
+}
+.card-image-box > img{
+    width: 70% !important;
+}

+ 77 - 0
views/product_service.xml

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- Form view -->
+        
+        <record model="ir.ui.view" id="product_service_form">
+            <field name="name">product.service.form</field>
+            <field name="model">product.service</field>
+            <field name="arch" type="xml">
+                <form string="Product Service">
+                    <sheet>
+                        <field name="logo" widget="image" class="oe_avatar oe_left"/>
+                        <div class="oe_title">
+                            <h2>
+                                <field name="product_service_brand_id" placeholder="Marca" required="1"/>
+                            </h2>
+                            <h2>
+                                <field name="model" placeholder="Modelo" required="1"/>
+                            </h2>
+                            <h2>
+                                <field name="number" placeholder="Número" required="1"/>
+                            </h2>
+
+                        </div>
+                        <notebook>
+                            <page string="Configuración">
+                                <group>
+                                    <group string="Información legal">
+                                        <field name="partner_id" string="Propietario" required="1" domain="[('customer','=',True)]"/>
+                                        <field name="valuation" string="Valoracion del producto"/>
+                                    </group>
+                                </group>
+                                <group>
+                                    <group string="Descripción">
+                                        <field name="description" nolabel="1"/>
+                                    </group>
+                                    <group string="Información Adicional">
+                                        <field name="year" string="Año"/>
+                                    </group>
+                                </group>
+                            </page>
+                        </notebook>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+        
+        <!-- tree view -->
+
+        <record model="ir.ui.view" id="product_service_tree" >
+            <field name="name">product_service_tree</field>
+            <field name="model">product.service</field>
+            <field name="arch" type="xml">
+                <tree string="Product">
+                    <field name="name"/>
+                    <field name="partner_id"/>
+                    <field name="valuation"/>
+                </tree>
+            </field>
+        </record>
+
+        <!-- action -->
+
+        <record model="ir.actions.act_window" id="product_service_action">
+            <field name="name">Productos</field>
+            <field name="res_model">product.service</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+        
+        <!-- menus -->
+
+        <menuitem
+            name="Registrar Producto" id="product_service_add_menu" action="product_service_action" parent="project_config_parent_menu"/>
+    </data>
+</openerp>

+ 86 - 0
views/product_service_brand.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- actions -->
+
+        <act_window
+            id="action_open_product_service"
+            name="Car Products"
+            res_model="product.service"
+            view_type="form"
+            view_mode="tree,form"
+            domain="[('product_service_brand_id', '=', active_id)]"/>
+
+        <act_window
+            id="action_open_single_product_service"
+            name="Car Brand"
+            res_model="product.service"
+            view_type="form"
+            view_mode="tree,form"
+            target="current"
+            domain="[('product_service_ids', 'in', active_id)]"/> 
+
+        <!-- form view -->
+
+        <record model="ir.ui.view" id="product_service_brand_form">
+            <field name="name">product_service_brand_form</field>
+            <field name="model">product.service.brand</field>
+            <field name="arch" type="xml">
+                <form string="Car Brand" version="7.0">
+                    <sheet>
+                        <field name="logo" widget="image" class="oe_avatar oe_left"/>
+                        <div class="oe_title">
+                            <div class="oe_edit_only">
+                                <label for="name" string="Marca"/>
+                            </div>
+                            <h1>
+                                <field name="name"/>
+                            </h1>
+                        </div>
+                        <div class="oe_right oe_button_box">
+                            <button
+                                class="oe_inline oe_stat_button"
+                                type="action"
+                                name="%(action_open_product_service)d"
+                                icon="fa-cubes">
+                                <field name="product_service_count" string="Productos" widget="statinfo" />
+                            </button>
+                        </div>
+                        <group string="Descripción">
+                            <field name="description" nolabel="1"/>
+                        </group>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+
+        <!-- Tree -->
+
+        <record model="ir.ui.view" id="product_service_brand_tree">
+            <field name="name">product.service.brand.tree</field>
+            <field name="model">product.service.brand</field>
+            <field name="arch" type="xml">
+                <tree string="Marca">
+                    <field name="name" string="Nombre"/>
+                    <field name="description" string="Descripción"/>
+                </tree>
+            </field>
+        </record>
+        
+        <!-- action -->
+
+        <record model="ir.actions.act_window" id="product_service_brand_action">
+            <field name="name">Marcas</field>
+            <field name="res_model">product.service.brand</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+        <!-- menu -->
+
+        <menuitem
+            name="Marcas" id="product_service_brand_all_menu" 
+            action="product_service_brand_action" parent="project_config_parent_menu"/>
+    </data>
+</openerp>

+ 161 - 0
views/project_service.xml

@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- actions -->
+        
+        <act_window
+            id="action_open_project_service_task"
+            name="Tareas"
+            res_model="project.service.task"
+            view_type="form"
+            view_mode="tree,form"
+            domain="[('project_id', '=', active_id)]"/>
+
+        <act_window
+            id="action_open_single_project_service_task"
+            name="Tareas"
+            res_model="project.service.task"
+            view_type="form"
+            view_mode="tree,form"
+            target="current"
+            domain="[('project_service_task_ids', 'in', active_id)]"/> 
+
+        <!-- Form view -->
+
+        <record model="ir.ui.view" id="project_service_form">
+            <field name="name">project.service.form</field>
+            <field name="model">project.service</field>
+            <field name="arch" type="xml">
+                <form string="Proyectos">
+                    <header>
+                        <field name="state" widget="statusbar" clickable="True"/>
+                    </header>
+                    <sheet>
+                        <field name="image_medium" widget='image' class="oe_avatar oe_left" attrs="{'readonly': [('state','=', 'close')]}"/>
+                        <div class="oe_title">
+                            <h1>
+                                <field name="name"/>
+                            </h1>
+                        </div>
+                        <div class="oe_right oe_button_box">
+                            <button
+                                class="oe_inline oe_stat_button"
+                                type="action"
+                                name="%(action_open_project_service_task)d"
+                                icon="fa-cubes">
+                                <field name="project_service_task_count" string="Tareas" widget="statinfo" />
+                            </button>
+                        </div>
+                        <notebook>
+                            <page string="Configuración">
+                                <group>
+                                    <group>
+                                        <field name="partner_id" string="Cliente" domain="[('customer', '=', True)]" attrs="{'readonly': [('state','=', 'close')]}" required="1"/>
+                                    </group>
+                                    <group name="extra_info">
+                                        <field name="date_in" string="Fecha de entrada" attrs="{'required': [('state','!=', 'draft')],'readonly': [('state','=', 'close')]}"/>
+                                        <field name="date_out" string="Fecha de salida" attrs="{'readonly': [('state','=', 'close')]}"/>
+                                    </group>
+                                </group>
+                            </page>
+                        </notebook>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+
+        <!-- Search view -->
+
+        <record model="ir.ui.view" id="project_service_search">
+            <field name="name">project.service.search</field>
+            <field name="model">project.service</field>
+            <field name="arch" type="xml">
+                <search string="Buscar Proyecto">
+                    <field name="name" string="Nombre"/>
+                    <filter string="Abierto" name="Current" domain="[('state', '=','open')]"/>
+                    <filter string="Pendiente" name="Pending" domain="[('state', '=','pending')]"/>
+                    <separator/>
+                    <separator/>
+                    <group expand="0" string="Agrupar por ">
+                        <filter string="Cliente" name="Partner" context="{'group_by':'partner_id'}"/>
+                    </group>
+                </search>
+            </field>
+        </record>
+
+        <!-- Kanban view -->
+
+        <record model="ir.ui.view" id="project_service_kanban">
+        <field name="name">project.service.kanban</field>
+        <field name="model">project.service</field>
+        <field name="arch" type="xml">
+            <kanban class="oe_background_grey">
+                <field name="name"/>
+                <field name="color"/> 
+                <field name="project_service_task_count"/>
+                <field name="project_service_task_ids"/>
+                <templates>
+                    <t t-name="kanban-box" class="project-card">
+                        <div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_project oe_kanban_global_click project-card">
+                            <div class="oe_dropdown_toggle oe_dropdown_kanban" groups="base.group_user">
+                                <span class="oe_e">í</span>
+                                <ul class="oe_dropdown_menu">
+                                    <t t-if="widget.view.is_action_enabled('edit')"><li><a type="edit">Configurar</a></li></t>
+                                    <li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
+                                </ul>
+                            </div>
+                            <div class="oe_kanban_content">
+                                <h4 class="text-center"><strong><field name="name"/></strong></h4>
+                                <div class="o_kanban_image text-center image_kanban_project card-image-box">
+                                    <img t-att-src="kanban_image('project.service', 'image_medium', record.id.value)" style="width:80%;"/>
+                                </div>
+                            </div>
+                            <div class="oe_kanban_project_list">
+                                <div class="o_project_kanban_box">
+                                    <a name="%(action_open_project_service_task)d" type="action" style="margin-right: 10px">
+                                        <t t-raw="record.project_service_task_count.raw_value"/>Tareas
+                                    </a>
+                                </div>
+                            </div>
+                        </div>
+                    </t>
+                </templates>
+            </kanban>
+        </field>
+        </record>
+
+        <!-- tree view -->
+
+        <record model="ir.ui.view" id="project_service_tree">
+            <field name="name">project.service.tree</field>
+            <field name="model">project.service</field>
+            <field name="arch" type="xml">
+                <tree  decoration-info="state in ('draft','pending')" decoration-muted="state in ('close','cancelled')" string="Vehicles">
+                    <field name="name" string="Nombre del Proyecto"/>
+                     <field name="partner_id" string="Cliente"/>
+                    <field name="state" string="Estado"/>
+                </tree>
+            </field>
+        </record>
+
+        <!-- action -->
+
+        <record model="ir.actions.act_window" id="project_service_action">
+            <field name="name">Proyectos</field>
+            <field name="res_model">project.service</field>
+            <field name="view_type">form</field>
+            <field name="domain">[]</field>
+            <field name="view_mode">kanban,tree,form</field>
+            <field name="search_view_id" ref="project_service_search"/>
+            <field name="context">{'search_default_Current': 1}</field>
+        </record>
+        
+        <!-- menus -->
+
+        <menuitem id="project_main_menu" name="Operaciones"/>
+        <menuitem name="Panel de Control" parent="project_main_menu" id="project_service_parent_menu" sequence="1"/>
+        <menuitem name="Todos los proyectos" parent="project_service_parent_menu" id="project_service_all_menu" sequence="1" action="project_service_action"/>
+        <menuitem name="Configuracion" parent="project_main_menu" id="project_config_parent_menu" sequence="5"/>
+    </data>
+</openerp>

+ 108 - 0
views/project_service_activity.xml

@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        
+        <!-- form view -->
+        
+        <record model="ir.ui.view" id="project_service_activity_form">
+            <field name="name">project.service.activity.form</field>
+            <field name="model">project.service.activity</field>
+            <field name="arch" type="xml">
+                <form string="Actividades">
+                    <sheet>
+                        <group>
+                            <div class="oe_title oe_left">
+                                <div class="oe_edit_only">
+                                    <label for="task_id" string="Tarea"/>
+                                </div>
+                                <h2>
+                                    <field name="task_id" placeholder="Tarea"/>
+                                </h2>
+                            </div>   
+                        </group>   
+                        <group>
+                            <group>
+                                <field name="product_id" string="Actividad planeada"/>
+                                <field name="time_spent" widget="float_time" string="Tiempo Estimado"/>
+                            </group>
+                            <group>
+                                <field name="user_id" string="Responsable"/>
+                                <field name="work_date" string="Fecha"/>
+                                <field name="work_cost" string="Costo"/>
+                            </group>
+                        </group>    
+                    </sheet>
+                </form>
+            </field>
+        </record>
+        
+        <!-- tree view -->
+        
+        <record model="ir.ui.view" id="project_service_activity_tree" > 
+           <field name="name">project.service.activity.tree</field>
+            <field name="model">project.service.activity</field>
+            <field name="arch" type="xml">
+                <tree string="tareas">
+                    <field name="user_id" string="Responsable"/>
+                    <field name="task_id" string="Trabajo"/>
+                    <field name="product_id" string="Actividad"/>
+                    <field name="work_date" string="Fecha"/>
+                    <field name="work_cost" string="Costo"/>
+                    <field name="completed" string="Estado"/>
+                </tree>
+            </field>
+        </record>
+        
+        <!-- calendar view -->
+        
+        <record model="ir.ui.view" id="project_service_activity_calendar">
+            <field name="name">project.service.activity.calendar</field>
+            <field name="model">project.service.activity</field>
+            <field eval="2" name="priority"/>
+            <field name="arch" type="xml">
+                <calendar color="user_id" date_start="work_date" string="Actividades">
+                    <field name="product_id"/>
+                    <field name="task_id"/>
+                </calendar>
+            </field>
+        </record>
+
+        <!-- Search -->
+
+        <record model="ir.ui.view" id="project_service_activity_search">
+            <field name="name">project.service.activity.search</field>
+            <field name="model">project.service.activity</field>
+            <field name="arch" type="xml">
+               <search string="Actividades">
+                    <field name="name" string="Actividad"/>
+                    <field name="user_id" string="Responsable"/>
+                    <field name="task_id" string="Tarea"/>
+                    <filter string="Mis Actividades" domain="[('user_id','=',uid)]"/>
+                    <separator/>
+                    <filter string="Terminados" name="End" domain="[('completed','=',1)]"/>
+                    <filter string="Pendientes" name="Pending" domain="[('completed','=',0)]"/>
+                    <separator/>
+                    <group expand="0" string="Agrupar por ">
+                        <filter string="Tarea" name="task" context="{'group_by':'task_id'}"/>
+                        <filter string="Responsables" name="User" context="{'group_by':'user_id'}"/>
+                        <separator/>
+                    </group>
+                </search>
+            </field>
+        </record>
+
+        <!-- action -->
+        
+        <record model="ir.actions.act_window" id="project_service_activity_action">
+            <field name="name">Todas las actividades</field>
+            <field name="res_model">project.service.activity</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form,calendar</field>
+        </record>
+        
+        <!-- menus -->
+        
+        <menuitem name="Control de Actividades" parent="project_main_menu" id="project_service_activity_parent_menu" sequence="3"/>
+        <menuitem name="Todos las Actividades" parent="project_service_activity_parent_menu" id="project_service_activity_all_menu" sequence="1" action="project_service_activity_action"/>
+    </data>
+</openerp>

+ 39 - 0
views/project_service_material.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        
+        <!-- form view -->
+        
+        <record model="ir.ui.view" id="project_service_material_form">
+            <field name="name">project.service.material.form</field>
+            <field name="model">project.service.material</field>
+            <field name="arch" type="xml">
+                <form string="Materiales">
+                    <group>
+                        <group>
+                            <field name="product_id" />
+                        </group>
+                        <group>
+                            <field name="amount"/>
+                            <field name="price"/>
+                        </group>
+                    </group>
+                </form>
+            </field>
+        </record>
+		
+        <!-- Tree view -->
+        
+        <record model="ir.ui.view" id="project_service_material_tree">
+            <field name="name">project.service.material.tree</field>
+            <field name="model">project.service.material</field>
+            <field name="arch" type="xml">
+                <tree string="Materiales" editable="bottom">
+                    <field name="product_id" />
+                    <field name="amount" sum="amount"/>
+                    <field name="price" sum="total"/>
+                </tree>
+            </field>
+        </record>
+    </data>
+</openerp>

+ 57 - 0
views/project_service_stage.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        
+        <!-- form view -->
+        
+        <record model="ir.ui.view" id="project_service_stage_form">
+            <field name="name">project.service.stage.form</field>
+            <field name="model">project.service.stage</field>
+            <field name="arch" type="xml">
+                <form string="Project Stages">
+                    <group>
+                        <group>
+                            <field name="name" string="Nombre de la etapa"/>
+                            <field name="sequence" groups="base.group_no_one" string="Sequencia"/>
+                        </group>
+                        <group>
+                            <field name="fold" string="Replegado en la lista kanban"/>
+                        </group>
+                    </group>
+                    <group>
+                        <field name="description" placeholder="Agregar descripción" nolabel="1" colspan="2"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <!-- tree view -->
+
+        <record model="ir.ui.view" id="project_service_stage_tree">
+           <field name="name">project.service.stage.tree</field>
+            <field name="model">project.service.stage</field>
+            <field name="arch" type="xml">
+                <tree string="Estado de la tarea">
+                    <field name="sequence" widget="handle" groups="base.group_no_one"/>
+                    <field name="name" string="Nombre de la etapa"/>
+                    <field name="fold" string="Replegado en la vista Kanban"/>
+                    <field name="description" string="Descripción"/>
+                </tree>
+            </field>
+        </record>
+        
+        <!-- action -->
+
+        <record model="ir.actions.act_window" id="project_service_stage_action">
+            <field name="name">Etapas</field>
+            <field name="res_model">project.service.stage</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+        
+        <!-- menus -->
+        
+        <menuitem action="project_service_stage_action" id="project_service_stage_all_menu" parent="project_config_parent_menu" string="Etapas"/>
+
+    </data>
+</openerp>

+ 230 - 0
views/project_service_task.xml

@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- actions -->
+
+        <act_window
+            id="action_open_account_invoice"
+            name="Tareas"
+            res_model="account.invoice"
+            view_type="form"
+            view_mode="tree,form"
+            domain="[('task_invoice_id', '=', active_id)]"/>
+
+        <act_window
+            id="action_open_single_account_invoice"
+            name="Tareas"
+            res_model="account.invoice"
+            view_type="form"
+            view_mode="tree,form"
+            target="current"
+            domain="[('invoice_ids', 'in', active_id)]"/> 
+
+        <!-- Form View -->
+        
+        <record model="ir.ui.view" id="project_service_task_form">
+            <field name="name">project.service.task.form</field>
+            <field name="model">project.service.task</field>
+            <field name="arch" type="xml">
+                <form string="Worksheet">
+                    <header>
+                        <button name="Facturado" string="Crear Factura" type="object" class="btn-primary" states="Preparado"/>
+                        
+                        <button class="btn-primary" name="cancel" string="Cancelar" type="object" states="Preparado"/>
+                        
+                        <button name="button_draft"
+                            states="Cancelado,Facturado"
+                            string="Cambiar Estado"
+                            type="object"/>
+                        
+                        <field name="stage_id" widget="statusbar" clickable="True"/>
+                        <field name="state" widget="statusbar" invisible="1"/>
+                    </header>
+                    <sheet string="Hoja de Tarea">
+                        <div class="oe_title">
+                            <h1 class="o_row">
+                                <field name="name" placeholder="Titulo de la tarea" attrs="{'readonly': [('state','!=', 'Preparado')]}"/>
+                            </h1> 
+                        </div>
+                        <div class="oe_right oe_button_box">
+                            <button
+                                class="oe_inline oe_stat_button"
+                                type="action"
+                                name="%(action_open_account_invoice)d"
+                                icon="fa-money">
+                                <field name="invoice_count" string="Facturas" widget="statinfo" />
+                            </button>
+                        </div>
+                        <group>
+                            <group>
+                                <field name="project_id" string="Proyecto" attrs="{'readonly': [('state','!=', 'Preparado')]}" domain="[('state','=','open')]"/>
+
+                                <field name="user_id" string="Responsable" attrs="{'readonly': [('state','!=', 'Preparado')]}"/>
+                            </group>
+                            <group>
+                                <field name="date_deadline" string="Fecha limite entrega" attrs="{'readonly': [('state','!=', 'Preparado')]}"/>
+                            </group>
+                        </group>
+                        <notebook>
+                            <page name="timesheet_page" string="Hoja de trabajo">
+                                <group string ="Trabajo Planeado">
+                                    <field name="activity_ids" nolabel="1" attrs="{'readonly': [('state','!=', 'Preparado')]}">
+                                        <tree string="Planned Work" editable="bottom">
+                                            <field name="product_id" string="Trabajo"/>
+                                            <field name="time_spent" sum= "Estimated Time" widget="float_time" string="Tiempo Estimado"/>
+                                            <field name="work_date" string="Fecha de trabajo"/>
+                                            <field name="user_id" string="Responsable"/>
+                                            <field name="work_cost" string="Precio" sum="total"/>
+                                            <field name="completed" string="¿El trabajo esta terminado?"/>
+                                        </tree>
+                                    </field>
+                                </group>
+                                <group string = "Materiales Utilizados">
+                                    <field name="materials_used" nolabel="1" attrs="{'readonly': [('state','!=', 'Preparado')]}"/>
+                                </group>
+                                <group>
+                                    <field name="include_materials" class="oe_inline" string="¿Incluir materiales en la factura?" attrs="{'readonly': [('state','!=', 'Preparado')]}"/>
+                                </group>
+                                <group>
+                                    <label for="amount_total" string="Monto Total"/>
+                                    <h1>
+                                        <field name="amount_total"/>
+                                    </h1>
+                                </group>
+                                 <group class="oe_subtotal_footer oe_right" name="project_hours">
+                                    <field name="effective_hour" widget="float_time" string="Horas Gastadas"/>
+                                </group>
+                            </page>
+                            <page string="Informacion Extra">
+                                <group col="4">
+                                    <group col="2">
+                                        <field name="partner_id" string="Cliente" required="1" readonly="1"/>
+                                    </group>
+                                    <group col="2">
+                                        <field name="date_assign" string="Fecha de creación"/>
+                                    </group>
+                                </group>
+                            </page>
+                        </notebook>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+        
+        <!-- Tree view -->
+        
+        <record model="ir.ui.view" id="project_service_task_tree">
+            <field name="name">project.service.task.tree</field>
+            <field name="model">project.service.task</field>
+            <field name="arch" type="xml">
+                <tree string="Tareas">
+                    <field name="name" string="Titulo"/>
+                    <field name="project_id" string="Proyecto"/>
+                    <field name="user_id" string="Asignado a"/>
+                    <field name="date_deadline" string="Fecha limite"/>
+                    <field name="stage_id" string="Etapa"/>
+                </tree>
+            </field>
+        </record>
+        
+        <!-- Kanban view -->
+        
+        <record model="ir.ui.view" id="project_service_task_kanban">
+            <field name="name">project.service.task.kanban</field>
+            <field name="model">project.service.task</field>
+            <field name="arch" type="xml">
+                <kanban default_group_by="stage_id">
+                    <field name="color"/>
+                    <field name="priority"/>
+                    <field name="user_id"/>
+                    <field name="description"/>
+                    <field name="date_deadline"/>                    
+                    <templates>
+                         <t t-name="kanban-box">
+                        <div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click">
+                            <div class="oe_dropdown_toggle oe_dropdown_kanban" groups="base.group_user">
+                                <span class="oe_e">í</span>
+                                <ul class="oe_dropdown_menu">
+                                    <t t-if="widget.view.is_action_enabled('edit')"><li><a type="edit">Edit...</a></li></t>
+                                    <t t-if="widget.view.is_action_enabled('delete')"><li><a type="delete">Delete</a></li></t>
+                                    <li><ul class="oe_kanban_colorpicker" data-field="color"/></li>
+                                </ul>
+                            </div>
+
+                            <div class="oe_kanban_content">
+                                <div><b><field name="name"/></b></div>
+                                <div>
+                                    <field name="project_id"/><br/>
+                                    <t t-if="record.date_deadline.raw_value and record.date_deadline.raw_value lt (new Date())" t-set="red">oe_kanban_text_red</t>
+                                    <span t-attf-class="#{red || ''}"><i><field name="date_deadline"/></i></span>
+                                </div>
+                                <div class="oe_kanban_bottom_right">
+                                    <img t-att-src="kanban_image('res.users', 'image_small', record.user_id.raw_value)" t-att-title="record.user_id.value" width="24" height="24" class="oe_kanban_avatar pull-right"/>
+                                </div>
+                            </div>
+                            <div class="oe_clear"></div>
+                        </div>
+                    </t>
+                    </templates>
+                </kanban>
+            </field>
+        </record>
+        
+        <!-- calendar view -->
+        
+        <record model="ir.ui.view" id="project_service_task_calendar">
+            <field name="name">project.service.task.calendar</field>
+            <field name="model">project.service.task</field>
+            <field eval="2" name="priority"/>
+            <field name="arch" type="xml">
+                <calendar color="user_id" date_start="date_deadline" string="Tasks">
+                    <field name="name"/>
+                    <field name="project_id"/>
+                </calendar>
+            </field>
+        </record>
+
+        <!-- search view -->
+
+        <record model="ir.ui.view" id="project_service_task_search">
+            <field name="name">project.service.task.search</field>
+            <field name="model">project.service.task</field>
+            <field name="arch" type="xml">
+               <search string="Tareas">
+                    <field name="name" string="Tarea"/>
+                    <field name="partner_id" string="Cliente"/>
+                    <field name="project_id" string="Proyecto"/>
+                    <field name="user_id" string="Responsable"/>
+                    <field name="stage_id" string="Etapa"/>
+                    <filter string="Mis tareas" domain="[('user_id','=',uid)]"/>
+                    <separator/>
+                    <filter string="Nuevo" name="draft" domain="[('stage_id.sequence', '&lt;=', 1)]"/>
+                    <separator/>
+                    <group expand="0" string="Agrupar por ">
+                        <filter string="Proyecto" name="project" context="{'group_by':'project_id'}"/>
+                        <filter string="Asignado a" name="User" context="{'group_by':'user_id'}"/>
+                        <filter string="Etapa" name="Stage" context="{'group_by':'stage_id'}"/>
+                        <filter string="Estado" name="State" context="{'group_by':'state'}"/>
+                        <separator/>
+                    </group>
+                </search>
+            </field>
+        </record> 
+        
+        <!-- action -->
+
+        <record model="ir.actions.act_window" id="project_service_task_action">
+            <field name="name">Tareas</field>
+            <field name="res_model">project.service.task</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">kanban,tree,form,calendar</field>
+        </record>
+
+        <!-- menus -->
+
+        <menuitem name="Control de tareas" id="project_service_task_parent_menu" parent="project_main_menu" sequence="2"/>
+        <menuitem name="Todas las Tareas" id="project_service_task_all_menu" parent="project_service_task_parent_menu" action="project_service_task_action"/>
+
+    </data>
+</openerp>

+ 10 - 0
views/template.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <template id="assets_backend" name="vehicle assets" inherit_id="web.assets_backend">
+            <xpath expr="." position="inside">
+                <link rel="stylesheet" href="/eiru_base_for_services/static/src/css/vehicles.css"/>
+            </xpath>
+        </template>
+    </data>
+</openerp>