|
@@ -72,7 +72,7 @@ class OrdenServicio(models.Model):
|
|
|
string='Distancia en km'
|
|
|
)
|
|
|
croquis = fields.Char(
|
|
|
- string='Croquis de la obra'
|
|
|
+ string='Croquis de la obra/Ubicación'
|
|
|
)
|
|
|
hrs_total = fields.Char(
|
|
|
string='Hora total del trabajo'
|
|
@@ -173,6 +173,7 @@ class OrdenServicio(models.Model):
|
|
|
# Esto puede requerir personalización adicional dependiendo de tu requisito exacto
|
|
|
url = record.ubicacion_google_link
|
|
|
|
|
|
+
|
|
|
class ProductoServicio(models.Model):
|
|
|
_name = 'servicio.producto'
|
|
|
|
|
@@ -181,8 +182,8 @@ class ProductoServicio(models.Model):
|
|
|
string='Orden de servicio'
|
|
|
)
|
|
|
|
|
|
- product_id = fields.Many2one('product.product', 'Producto')
|
|
|
- categ_id = fields.Many2one('product.category', 'Categoría de producto')
|
|
|
+ product_id = fields.Many2one('product.product', 'Producto', domain=[('type', '=', 'product')])
|
|
|
+ categ_id = fields.Char('Categoría de producto')
|
|
|
quantity = fields.Float(
|
|
|
string='Cantidad',
|
|
|
default=1,
|
|
@@ -196,6 +197,17 @@ 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:
|
|
|
+ self.description = self.product_id.name
|
|
|
+ self.categ_id = self.product_id.categ_id.name
|
|
|
+ self.type = 'product' if self.product_id.type == 'product' \
|
|
|
+ else 'service'
|
|
|
+
|
|
|
+ # @ TODO impuestos??
|
|
|
+ # Obtener el precio del producto a partir de la tarifa del cliente
|
|
|
+ self.price_unit = self.product_id.list_price
|
|
|
|
|
|
class ServicioInsumo(models.Model):
|
|
|
_name = 'servicio.insumo'
|
|
@@ -206,10 +218,7 @@ class ServicioInsumo(models.Model):
|
|
|
comodel_name='orden.servicio',
|
|
|
string='Orden de servicio'
|
|
|
)
|
|
|
- product_id = fields.Many2one(
|
|
|
- comodel_name='product.product',
|
|
|
- string='Insumos'
|
|
|
- )
|
|
|
+ product_id = fields.Many2one('product.product', 'Producto', domain=[('type', '=', 'product')])
|
|
|
descripcion = fields.Char(
|
|
|
string='Descripcion',
|
|
|
required=True
|
|
@@ -238,6 +247,7 @@ class ServicioInsumo(models.Model):
|
|
|
def onchange_product_id(self):
|
|
|
if self.product_id:
|
|
|
self.description = self.product_id.name
|
|
|
+ self.price_unit = self.product_id.list_price
|
|
|
|
|
|
class ServicioLogistica(models.Model):
|
|
|
_name = 'servicio.logistica'
|
|
@@ -248,16 +258,17 @@ class ServicioLogistica(models.Model):
|
|
|
comodel_name='orden.servicio',
|
|
|
string='Orden de servicio'
|
|
|
)
|
|
|
- product_id = fields.Many2one(
|
|
|
- comodel_name='product.product',
|
|
|
- string='Servicios'
|
|
|
+ fecha = fields.Date(
|
|
|
+ string='Fecha',
|
|
|
+ required=True
|
|
|
)
|
|
|
+ product_id = fields.Many2one('product.product', 'Servicio', domain=[('type', '=', 'service'), ('categ_id', '=', 'Gastos')])
|
|
|
descripcion = fields.Char(
|
|
|
string='Descripcion',
|
|
|
required=True
|
|
|
)
|
|
|
quantity = fields.Float(
|
|
|
- string='Cantidad',
|
|
|
+ string='Km recorrido',
|
|
|
default=1
|
|
|
)
|
|
|
price_unit = fields.Float(
|
|
@@ -274,6 +285,13 @@ class ServicioLogistica(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:
|
|
|
+ self.description = self.product_id.name
|
|
|
+ self.price_unit = self.product_id.list_price
|
|
|
+
|
|
|
+
|
|
|
class DevolucionInsumo(models.Model):
|
|
|
_name = 'devolucion.insumo'
|
|
|
_description = 'Devolución de productos e insumos'
|
|
@@ -283,10 +301,7 @@ class DevolucionInsumo(models.Model):
|
|
|
comodel_name='orden.servicio',
|
|
|
string='Orden de servicio'
|
|
|
)
|
|
|
- product_id = fields.Many2one(
|
|
|
- comodel_name='product.product',
|
|
|
- string='Productos e insumos'
|
|
|
- )
|
|
|
+ product_id = fields.Many2one('product.product', 'Producto', domain=[('type', '=', 'product')])
|
|
|
descripcion = fields.Char(
|
|
|
string='Descripcion',
|
|
|
required=True
|
|
@@ -311,6 +326,12 @@ class DevolucionInsumo(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:
|
|
|
+ self.description = self.product_id.name
|
|
|
+ self.price_unit = self.product_id.list_price
|
|
|
+
|
|
|
|
|
|
class RecepcionFabrica(models.Model):
|
|
|
_name = 'recepcion.fabrica'
|
|
@@ -321,6 +342,10 @@ class RecepcionFabrica(models.Model):
|
|
|
comodel_name='orden.servicio',
|
|
|
string='Orden de servicio'
|
|
|
)
|
|
|
+ fecha = fields.Date(
|
|
|
+ string='Fecha',
|
|
|
+ required=True
|
|
|
+ )
|
|
|
product_id = fields.Many2one(
|
|
|
comodel_name='product.product',
|
|
|
string='Productos'
|
|
@@ -341,13 +366,21 @@ class RecepcionFabrica(models.Model):
|
|
|
compute='compute_subtotal',
|
|
|
digits=(10, 0)
|
|
|
)
|
|
|
+ employee_id = fields.Many2one(
|
|
|
+ 'hr.employee',
|
|
|
+ string='Empleado'
|
|
|
+ )
|
|
|
|
|
|
@api.one
|
|
|
@api.depends('quantity', 'price_unit')
|
|
|
def compute_subtotal(self):
|
|
|
self.subtotal = self.quantity * self.price_unit
|
|
|
|
|
|
-
|
|
|
+ @api.onchange('product_id')
|
|
|
+ def onchange_product_id(self):
|
|
|
+ if self.product_id:
|
|
|
+ self.description = self.product_id.name
|
|
|
+ self.price_unit = self.product_id.list_price
|
|
|
|
|
|
class AccountInvoice(models.Model):
|
|
|
_inherit = 'account.invoice'
|