|
@@ -2,7 +2,7 @@
|
|
|
# License, author and contributors information in:
|
|
|
# __openerp__.py file at the root folder of this module.
|
|
|
|
|
|
-from openerp import api, models, fields
|
|
|
+from openerp import api, models, fields, _
|
|
|
from openerp.exceptions import ValidationError, except_orm, Warning, RedirectWarning
|
|
|
from openerp.tools import DEFAULT_SERVER_TIME_FORMAT
|
|
|
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
|
@@ -39,6 +39,8 @@ class OrdenServicio(models.Model):
|
|
|
celular_partner = fields.Char(related='partner_id.mobile', string='Móvil', store=True)
|
|
|
telefono_partner = fields.Char(related='partner_id.phone', string='Teléfono', store=True)
|
|
|
ubicacion_google_link = fields.Char(string='Ubicación Google Link')
|
|
|
+ currency_id = fields.Many2one('res.currency', string='Moneda Base')
|
|
|
+ company_id = fields.Many2one('res.company', string='Empresa')
|
|
|
name_obra = fields.Char(
|
|
|
string='Obra'
|
|
|
)
|
|
@@ -116,15 +118,12 @@ class OrdenServicio(models.Model):
|
|
|
comodel_name='recepcion.fabrica',
|
|
|
inverse_name='servicio_id',
|
|
|
string='Recepción en fábrica'
|
|
|
- )
|
|
|
-
|
|
|
+ )
|
|
|
invoice_ids = fields.One2many('account.invoice', 'servicio_invoice_id')
|
|
|
invoice_count = fields.Integer(
|
|
|
string='Facturas',
|
|
|
compute='_get_invoice_count',
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
+ )
|
|
|
state = fields.Selection([
|
|
|
('draft', 'Pendiente'),
|
|
|
('in_progress', 'En progreso'),
|
|
@@ -133,6 +132,61 @@ class OrdenServicio(models.Model):
|
|
|
string='Estado',
|
|
|
default='draft'
|
|
|
)
|
|
|
+ @api.multi
|
|
|
+ @api.depends('product_ids.subtotal')
|
|
|
+ def _compute_total_producto(self):
|
|
|
+ for record in self:
|
|
|
+ record.total_producto = sum(record.product_ids.mapped('subtotal'))
|
|
|
+
|
|
|
+ @api.multi
|
|
|
+ @api.depends('insumos_ids.subtotal')
|
|
|
+ def _compute_total_insumo(self):
|
|
|
+ for record in self:
|
|
|
+ record.total_insumo = sum(record.insumos_ids.mapped('subtotal'))
|
|
|
+
|
|
|
+ @api.multi
|
|
|
+ @api.depends('product_ids.subtotal')
|
|
|
+ def _compute_total_logistica(self):
|
|
|
+ for record in self:
|
|
|
+ record.total_logistica = sum(record.logistica_ids.mapped('subtotal'))
|
|
|
+
|
|
|
+ @api.multi
|
|
|
+ @api.depends('insumos_ids.subtotal')
|
|
|
+ def _compute_total_devolucion(self):
|
|
|
+ for record in self:
|
|
|
+ record.total_devolucion = sum(record.devolucion_ids.mapped('subtotal'))
|
|
|
+
|
|
|
+ @api.multi
|
|
|
+ @api.depends('insumos_ids.subtotal')
|
|
|
+ def _compute_total_fabrica(self):
|
|
|
+ for record in self:
|
|
|
+ record.total_fabrica = sum(record.recepcion_ids.mapped('subtotal'))
|
|
|
+
|
|
|
+ @api.depends('total_producto', 'total_insumo', 'total_logistica', 'total_devolucion', 'total_fabrica')
|
|
|
+ def _compute_total_obra(self):
|
|
|
+ for record in self:
|
|
|
+ record.total_obra = record.total_producto + record.total_insumo + record.total_logistica + record.total_devolucion + record.total_fabrica
|
|
|
+
|
|
|
+ total_producto = fields.Float(compute='_compute_total_producto', string='Total Producto', store=True)
|
|
|
+ total_insumo = fields.Float(compute='_compute_total_insumo', string='Total Insumo', store=True)
|
|
|
+ total_logistica = fields.Float(compute='_compute_total_logistica', string='Total Logística', store=True)
|
|
|
+ total_devolucion = fields.Float(compute='_compute_total_devolucion', string='Total Devolución', store=True)
|
|
|
+ total_fabrica = fields.Float(compute='_compute_total_fabrica', string='Total Recepción', store=True)
|
|
|
+ total_obra = fields.Float(compute='_compute_total_obra', string='Total Obra', store=True)
|
|
|
+
|
|
|
+
|
|
|
+ @api.model
|
|
|
+ def defaults(self):
|
|
|
+ res = super(OrderServicio, self).defaults()
|
|
|
+ company_id = self.env['res.company']._company_default_get('order.servicio')
|
|
|
+ currency_id = company_id.currency_id.id if company_id.currency_id else False
|
|
|
+
|
|
|
+ res.update({
|
|
|
+ 'currency_id': currency_id,
|
|
|
+ 'company_id': company_id.id,
|
|
|
+ })
|
|
|
+
|
|
|
+ return res
|
|
|
|
|
|
@api.one
|
|
|
@api.depends('invoice_ids')
|
|
@@ -197,6 +251,7 @@ class ProductoServicio(models.Model):
|
|
|
def compute_subtotal(self):
|
|
|
self.subtotal = self.quantity * self.price_unit
|
|
|
|
|
|
+
|
|
|
@api.onchange('product_id')
|
|
|
def onchange_product_id(self):
|
|
|
if self.product_id:
|
|
@@ -243,6 +298,7 @@ class ServicioInsumo(models.Model):
|
|
|
def compute_subtotal(self):
|
|
|
self.subtotal = self.quantity * self.price_unit
|
|
|
|
|
|
+
|
|
|
@api.onchange('product_id')
|
|
|
def onchange_product_id(self):
|
|
|
if self.product_id:
|