|
@@ -12,16 +12,27 @@ class import_purchase_line(models.Model):
|
|
_name = 'import.purchase.line'
|
|
_name = 'import.purchase.line'
|
|
|
|
|
|
import_id = fields.Many2one('import.cost', 'Compras de importación',ondelete='cascade')
|
|
import_id = fields.Many2one('import.cost', 'Compras de importación',ondelete='cascade')
|
|
- purchase_id = fields.Many2one('account.invoice', 'Compras',required=True)
|
|
|
|
|
|
+ purchase_id = fields.Many2one('account.invoice', 'Compras',required=True, domain=[('type', '=', 'in_invoice')])
|
|
purchase_subtotal = fields.Float("Subtotal", related='purchase_id.amount_untaxed', store=True, readonly=True)
|
|
purchase_subtotal = fields.Float("Subtotal", related='purchase_id.amount_untaxed', store=True, readonly=True)
|
|
purchase_taxes = fields.Float("Impuestos", related='purchase_id.amount_tax', store=True, readonly=True)
|
|
purchase_taxes = fields.Float("Impuestos", related='purchase_id.amount_tax', store=True, readonly=True)
|
|
purchase_total = fields.Float("Total", related='purchase_id.amount_total', store=True, readonly=True)
|
|
purchase_total = fields.Float("Total", related='purchase_id.amount_total', store=True, readonly=True)
|
|
|
|
+ product_qty = fields.Float("Producto por factura", compute="get_invoice_product_qty", store=True)
|
|
|
|
+
|
|
|
|
+ @api.one
|
|
|
|
+ @api.depends('purchase_id')
|
|
|
|
+ def get_invoice_product_qty(self):
|
|
|
|
+ suma = 0
|
|
|
|
+ for item in self.purchase_id.invoice_line:
|
|
|
|
+ line = self.env['account.invoice.line'].search([('id','=',item.id)])
|
|
|
|
+ suma = suma + line.quantity
|
|
|
|
+ self.product_qty = suma
|
|
|
|
+
|
|
|
|
|
|
class import_expense_line(models.Model):
|
|
class import_expense_line(models.Model):
|
|
_name = 'import.expense.line'
|
|
_name = 'import.expense.line'
|
|
|
|
|
|
import_id = fields.Many2one('import.cost', 'Gastos de importación',ondelete='cascade')
|
|
import_id = fields.Many2one('import.cost', 'Gastos de importación',ondelete='cascade')
|
|
- expense_id = fields.Many2one('account.invoice', 'Gastos', required=True)
|
|
|
|
|
|
+ expense_id = fields.Many2one('account.invoice', 'Gastos', required=True, domain=[('type', '=', 'in_invoice')])
|
|
expense_subtotal = fields.Float("Subtotal", related='expense_id.amount_untaxed', store=True, readonly=True)
|
|
expense_subtotal = fields.Float("Subtotal", related='expense_id.amount_untaxed', store=True, readonly=True)
|
|
expense_taxes = fields.Float("Impuestos", related='expense_id.amount_tax', store=True, readonly=True)
|
|
expense_taxes = fields.Float("Impuestos", related='expense_id.amount_tax', store=True, readonly=True)
|
|
expense_total = fields.Float("Total", related='expense_id.amount_total', store=True, readonly=True)
|
|
expense_total = fields.Float("Total", related='expense_id.amount_total', store=True, readonly=True)
|
|
@@ -43,41 +54,54 @@ class import_cost(models.Model):
|
|
approved_by = fields.Many2one('res.users', 'Aprobado por')
|
|
approved_by = fields.Many2one('res.users', 'Aprobado por')
|
|
customs_broker = fields.Many2one('res.partner', 'Despachante')
|
|
customs_broker = fields.Many2one('res.partner', 'Despachante')
|
|
customs_clearance = fields.Char('Despacho Nro')
|
|
customs_clearance = fields.Char('Despacho Nro')
|
|
- product_qty = fields.Float('Cantidad de productos')
|
|
|
|
|
|
+
|
|
|
|
+ @api.multi
|
|
|
|
+ def _get_qty(self):
|
|
|
|
+ for x in self:
|
|
|
|
+ suma = 0
|
|
|
|
+ purchase = self.env['import.purchase.line'].search([('import_id','=',x.id)])
|
|
|
|
+ for each in purchase:
|
|
|
|
+ suma = suma + each.product_qty
|
|
|
|
+
|
|
|
|
+ x.product_qty = suma
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ product_qty = fields.Float('Cantidad de productos', compute="_get_qty")
|
|
note = fields.Char('Observación')
|
|
note = fields.Char('Observación')
|
|
currency_id = fields.Many2one('res.currency', 'Moneda')
|
|
currency_id = fields.Many2one('res.currency', 'Moneda')
|
|
weight = fields.Float('Peso')
|
|
weight = fields.Float('Peso')
|
|
|
|
|
|
-
|
|
|
|
- @api.one
|
|
|
|
|
|
+ @api.multi
|
|
def _get_amount(self):
|
|
def _get_amount(self):
|
|
- suma_purchase_subtotal = 0
|
|
|
|
- suma_purchase_taxes = 0
|
|
|
|
- suma_purchase_total = 0
|
|
|
|
- suma_expense_subtotal = 0
|
|
|
|
- suma_expense_taxes = 0
|
|
|
|
- suma_expense_total = 0
|
|
|
|
-
|
|
|
|
- invoice1 = self.env['import.purchase.line'].search([('import_id','=',self.id)])
|
|
|
|
-
|
|
|
|
- for each in invoice1:
|
|
|
|
- suma_purchase_subtotal = suma_purchase_subtotal + each.purchase_subtotal
|
|
|
|
- suma_purchase_taxes = suma_purchase_taxes + each.purchase_taxes
|
|
|
|
- suma_purchase_total = suma_purchase_total + each.purchase_total
|
|
|
|
-
|
|
|
|
- invoice2 = self.env['import.expense.line'].search([('import_id','=',self.id)])
|
|
|
|
-
|
|
|
|
- for item in invoice2:
|
|
|
|
- suma_expense_subtotal = suma_expense_subtotal + item.expense_subtotal
|
|
|
|
- suma_expense_taxes = suma_expense_taxes + item.expense_taxes
|
|
|
|
- suma_expense_total = suma_expense_total + item.expense_total
|
|
|
|
-
|
|
|
|
- self.purchases_subtotal = suma_purchase_subtotal
|
|
|
|
- self.purchases_taxes = suma_purchase_taxes
|
|
|
|
- self.purchases_total = suma_purchase_total
|
|
|
|
- self.expenses_subtotal = suma_expense_subtotal
|
|
|
|
- self.expenses_taxes = suma_expense_taxes
|
|
|
|
- self.expenses_total = suma_expense_total
|
|
|
|
|
|
+ for x in self:
|
|
|
|
+ suma_purchase_subtotal = 0
|
|
|
|
+ suma_purchase_taxes = 0
|
|
|
|
+ suma_purchase_total = 0
|
|
|
|
+ suma_expense_subtotal = 0
|
|
|
|
+ suma_expense_taxes = 0
|
|
|
|
+ suma_expense_total = 0
|
|
|
|
+
|
|
|
|
+ invoice1 = self.env['import.purchase.line'].search([('import_id','=',x.id)])
|
|
|
|
+
|
|
|
|
+ for each in invoice1:
|
|
|
|
+ suma_purchase_subtotal = suma_purchase_subtotal + each.purchase_subtotal
|
|
|
|
+ suma_purchase_taxes = suma_purchase_taxes + each.purchase_taxes
|
|
|
|
+ suma_purchase_total = suma_purchase_total + each.purchase_total
|
|
|
|
+
|
|
|
|
+ invoice2 = self.env['import.expense.line'].search([('import_id','=',x.id)])
|
|
|
|
+
|
|
|
|
+ for item in invoice2:
|
|
|
|
+ suma_expense_subtotal = suma_expense_subtotal + item.expense_subtotal
|
|
|
|
+ suma_expense_taxes = suma_expense_taxes + item.expense_taxes
|
|
|
|
+ suma_expense_total = suma_expense_total + item.expense_total
|
|
|
|
+
|
|
|
|
+ x.purchases_subtotal = suma_purchase_subtotal
|
|
|
|
+ x.purchases_taxes = suma_purchase_taxes
|
|
|
|
+ x.purchases_total = suma_purchase_total
|
|
|
|
+ x.expenses_subtotal = suma_expense_subtotal
|
|
|
|
+ x.expenses_taxes = suma_expense_taxes
|
|
|
|
+ x.expenses_total = suma_expense_total
|
|
|
|
+
|
|
|
|
|
|
purchases_subtotal = fields.Float(string="Subtotal", compute="_get_amount")
|
|
purchases_subtotal = fields.Float(string="Subtotal", compute="_get_amount")
|
|
purchases_taxes = fields.Float(string="Impuestos", compute="_get_amount")
|
|
purchases_taxes = fields.Float(string="Impuestos", compute="_get_amount")
|
|
@@ -86,6 +110,10 @@ class import_cost(models.Model):
|
|
expenses_taxes = fields.Float(string="Impuestos", compute="_get_amount")
|
|
expenses_taxes = fields.Float(string="Impuestos", compute="_get_amount")
|
|
expenses_total = fields.Float(string="Total", compute="_get_amount")
|
|
expenses_total = fields.Float(string="Total", compute="_get_amount")
|
|
|
|
|
|
|
|
+ @api.multi
|
|
|
|
+ def button_dummy(self):
|
|
|
|
+ return True
|
|
|
|
+
|
|
@api.model
|
|
@api.model
|
|
def approve_import_cost(self, value):
|
|
def approve_import_cost(self, value):
|
|
approved_by = self.env.user.id
|
|
approved_by = self.env.user.id
|