deisy 5 년 전
부모
커밋
e044b2e602
7개의 변경된 파일74개의 추가작업 그리고 37개의 파일을 삭제
  1. BIN
      __init__.pyc
  2. 2 1
      __openerp__.py
  3. BIN
      models/__init__.pyc
  4. 60 32
      models/import_cost_calculation.py
  5. BIN
      models/import_cost_calculation.pyc
  6. 4 0
      security/ir.model.access.csv
  7. 8 4
      views/import_cost_calculation.xml

BIN
__init__.pyc


+ 2 - 1
__openerp__.py

@@ -18,9 +18,10 @@
         'static/src/xml/*.xml',
     ],
     'data': [
+        'template.xml',
+        'security/ir.model.access.csv',
         'data/ir_sequence.xml',
         'views/import_cost_calculation.xml',
-        'template.xml',
         ],
 
     'installable':True,

BIN
models/__init__.pyc


+ 60 - 32
models/import_cost_calculation.py

@@ -12,16 +12,27 @@ class import_purchase_line(models.Model):
     _name = 'import.purchase.line'
 
     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_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)
+    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):
     _name = 'import.expense.line'
 
     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_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)
@@ -43,41 +54,54 @@ class import_cost(models.Model):
     approved_by = fields.Many2one('res.users', 'Aprobado por')
     customs_broker = fields.Many2one('res.partner', 'Despachante')
     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')
     currency_id = fields.Many2one('res.currency', 'Moneda')
     weight = fields.Float('Peso')
 
-
-    @api.one
+    @api.multi
     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_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_total = fields.Float(string="Total", compute="_get_amount")
 
+    @api.multi
+    def button_dummy(self):
+        return True
+
     @api.model
     def approve_import_cost(self, value):
         approved_by = self.env.user.id

BIN
models/import_cost_calculation.pyc


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

@@ -0,0 +1,4 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_import_cost,import.cost,model_import_cost,base.group_sale_manager,1,1,1,1
+access_import_expense_line,import.expense.line,model_import_expense_line,base.group_sale_manager,1,1,1,1
+access_import_purchase_line,import.purchase.line,model_import_purchase_line,base.group_sale_manager,1,1,1,1

+ 8 - 4
views/import_cost_calculation.xml

@@ -24,7 +24,7 @@
                   <field name="note"/>
               </group>
               <group>
-                <field name="product_qty"/>
+                <field name="product_qty" readonly="1"/>
                 <field name="currency_id"/>
                 <field name="weight" readonly="1"/>
                 <field name="created_by" readonly="1"/>
@@ -32,12 +32,12 @@
               </group>
             </group>
 
-
             <group string="Facturas de compras"></group>
             <group>
               <field name="purchases"  nolabel="1" attrs="{'readonly': [('state','=', 'approved')]}">
                 <tree string="Detalles" editable="bottom" >
-                  <field name="purchase_id" domain="[('type', '=', 'in_invoice')]"/>
+                  <field name="purchase_id" domain="['|',('origin', 'ilike', 'PO'),('origin', '!=', False),('type', '=', 'in_invoice'),('state','=','paid')]"/>
+                  <field name="product_qty" readonly="1"/>
                   <field name="purchase_subtotal"/>
                   <field name="purchase_taxes"/>
                   <field name="purchase_total"/>
@@ -49,6 +49,8 @@
               <field name="purchases_taxes" widget='monetary'/>
               <div class="oe_subtotal_footer_separator oe_inline">
                 <label for="purchases_total"/>
+                <button name="button_dummy"
+                    states="draft" string="Actualizar" type="object" class="oe_edit_only oe_link"/>
               </div>
               <field name="purchases_total" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary'/>
             </group>
@@ -57,7 +59,7 @@
             <group>
               <field name="expenses" nolabel="1" attrs="{'readonly': [('state','=', 'approved')]}">
                 <tree string="Detalles" editable="bottom" >
-                  <field name="expense_id" domain="[('type', '=', 'in_invoice')]"/>
+                  <field name="expense_id" domain="['|',('origin', 'ilike', 'AA'),('origin', '=', False),('type', '=', 'in_invoice'),('state','=','paid')]"/>
                   <field name="expense_subtotal"/>
                   <field name="expense_taxes"/>
                   <field name="expense_total"/>
@@ -69,6 +71,8 @@
               <field name="expenses_taxes" widget='monetary' />
               <div class="oe_subtotal_footer_separator oe_inline">
                 <label for="expenses_total"/>
+                <button name="button_dummy"
+                    states="draft,sent" string="Actualizar" type="object" class="oe_edit_only oe_link"/>
               </div>
               <field name="expenses_total" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary'/>
             </group>