瀏覽代碼

commit inicial

Adrielso 8 年之前
當前提交
801f099ec8
共有 9 個文件被更改,包括 152 次插入0 次删除
  1. 3 0
      __init__.py
  2. 二進制
      __init__.pyc
  3. 11 0
      __openerp__.py
  4. 3 0
      model/__init__.py
  5. 二進制
      model/__init__.pyc
  6. 88 0
      model/account_invoice_move_line.py
  7. 二進制
      model/account_invoice_move_line.pyc
  8. 二進制
      static/description/icon.png
  9. 47 0
      view/account_invoice_move.xml

+ 3 - 0
__init__.py

@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import  model

二進制
__init__.pyc


+ 11 - 0
__openerp__.py

@@ -0,0 +1,11 @@
+# -*- coding: utf-8 -*-
+{
+    'name': 'Edit Move Line',
+    'version': '1.0',
+    'author': 'Adrielso Kunert',
+    'category': 'Accounting & Finance',
+    'depends': ['sale'],
+    'data': [  'view/account_invoice_move.xml',],
+    'installable': True,
+    'auto_install': False,
+ }

+ 3 - 0
model/__init__.py

@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import account_invoice_move_line

二進制
model/__init__.pyc


+ 88 - 0
model/account_invoice_move_line.py

@@ -0,0 +1,88 @@
+# -*- coding: utf-8 -*-
+
+from openerp import models, fields, api
+from openerp.osv import osv
+
+class invoice_interes(models.Model):
+    _inherit = "account.invoice"
+    _name = "account.invoice"
+
+    move_line_debt = fields.One2many('account.move.line', inverse_name="invoice", string="id Move line", domain=['&', ('reconcile_id', '=', False), '&', ('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')])
+    state_move_line= fields.Boolean(readonly=True, default=False)
+
+
+
+    @api.multi
+    def update_ammount_move(self):
+        # Variables
+        total_voucher=0
+        monto_residual=0
+        cuota_dividida=0
+        estado =None
+        cambio_py=0
+
+        if len(self.payment_ids) < 1:
+            raise osv.except_osv('Advertencia','No es posible continuar con la operación, para generar la división del saldo es necesario que pague su primera entrega')
+            return
+        #Verifica si  existe mas de una linea en move live
+        if len(self.move_line_debt) > 1:
+            # Actulizar estado del journal cuando tipo es venta
+            datos_journal = self.env['account.journal'].search([('type', '=', 'sale')])
+            datos_journal.write({'entry_posted' : True})
+
+            # rate_model = self.env['res.currency.rate'].search([('currency_id', '=', 166)])
+            # rate_py = rate_model[len(rate_model)-1]
+            # cambio_py =rate_py.rate
+
+            if self.currency_id.id == 3:
+                monto_residual = self.residual
+            else:
+                monto_residual = self.residual/self.currency_id.rate_ids.rate
+
+            # Calular la divicion la cuota
+            cuota_dividida = (monto_residual / len(self.move_line_debt))
+            print(monto_residual)
+            print(cuota_dividida)
+            for move_line in self.move_line_debt:
+                move_dato = self.env['account.move'].search([('id', 'in', move_line.move_id.ids)])
+                if move_dato:
+                    estado = move_dato.state
+                move_dato.write({'state' : 'draft'})
+
+                line_voucher = self.env['account.voucher.line'].search([('move_line_id', '=', move_line.id), ('amount', '>', 0)],order='id')
+                print(line_voucher)
+                if line_voucher:
+                    for voucher in line_voucher:
+
+                        if voucher.voucher_id.payment_rate_currency_id.id == 3:
+                            print("moneda Dolar ")
+                            total_voucher += voucher.amount
+                        else:
+                            print("ota moneda")
+                            print("Cambio "+str(voucher.voucher_id.payment_rate_currency_id))
+                            total_voucher +=(voucher.amount / voucher.voucher_id.payment_rate_currency_id.rate_ids.rate)
+
+                print("cuota "+str(cuota_dividida))
+                print("pagado " +str(total_voucher))
+                print('total '+str(cuota_dividida + total_voucher))
+                move_line_dato = self.env['account.move.line'].search([('id', '=', move_line.id)])
+                move_line_dato.write({'debit' : (cuota_dividida + total_voucher)})
+
+                # move_line_dato.write({'amount_currency' : ((move_line_dato.debit - move_line_dato.credit)*cambio_py)})
+
+                if  estado == None:
+                    estado='draft'
+                move_dato.write({'state' : estado})
+
+                # move_line_dato._amount_residual(move_line_dato.amount_residual_currency)
+
+            datos_journal.write({'entry_posted' : False})
+            incoice_datos = self.env['account.invoice'].search([('id', '=',self.id )])
+            incoice_datos.write({'state_move_line' : True})
+
+            move_line_state = self.env['account.move.line'].search([('ref', '=', self.number)])
+            move_line_state.write({'state' : 'valid'})
+
+        else:
+            raise osv.except_osv('Advertencia','No es posible generar la división  del saldo sobre una única linea')
+            return

二進制
model/account_invoice_move_line.pyc


二進制
static/description/icon.png


+ 47 - 0
view/account_invoice_move.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+    <record id="invoice_move_line_edit" model="ir.ui.view">
+      <field name="name">invoice.move.line.edit</field>
+      <field name="model">account.invoice</field>
+      <field name="inherit_id" ref="account.invoice_form"/>
+      <field name="arch" type="xml">
+        <notebook>
+            <page string="Seguimiento de Pagos">
+                <group col="4" class="table-bordered" >
+                  <group >
+                    <field name="state_move_line" invisible="1"/>
+                    <label for="actualizar_move_line" string="Actualizar Monto de las Cuotas "/>
+                    <button name="update_ammount_move" id="actualizar_move_line" type="object"  string="Aceptar"
+                            attrs="{'invisible': ['|','|',('state_move_line','!=', False), ('state','!=','open'), ('sent','=',True)]}"
+                            help="Actualizar los monto de las cuotas (Monto del saldo / cantidad de Cuota)"
+                            class="oe_button oe_form_button oe_highlight col-md-8 col-xs-12 center"/>
+                  </group>
+                  <group>
+                    <!-- <field name="date_due_new" string="Nueva fecha de Vencimientos"/> -->
+                    <!-- <label for="actualizar_date_due" string="Actualizar Fecha de Vencimientos"/> -->
+                    <!-- <button name="Update_date_due_move" id="actualizar_date_due" type="object"  string="Aceptar"
+                          help="Cambiara Automaticamente la Fecha de vencimientos de las cuota Pendiente"
+                          class="oe_button oe_form_button oe_highlight col-md-8 col-xs-12" /> -->
+                  </group>
+                </group>
+
+              <!-- tree  -->
+              <field name="move_line_debt" >
+                <tree string="Account Move line" editable="bottom" create="false" delete="false" >
+                  <!-- colors="red:(not date_maturity or date_maturity&lt;=current_date) and result&gt;0"> -->
+                    <!-- <field name="date" readonly="True"/> -->
+                    <field name="date_maturity" readonly="True"/>
+                    <field name="reconcile_partial_id" readonly="True"/>
+                    <!-- <field name="result" readonly="True" string=""/> -->
+                    <!-- <field name="amount_residual" string="Saldo $"/> -->
+                    <!-- <field name="amount_currency" string="Saldo ₲"/> -->
+                    <field name="debit"/>
+                </tree>
+              </field>
+            </page>
+        </notebook>
+      </field>
+    </record>
+  </data>
+</openerp>