Browse Source

commit inicial

Rodney Enciso Arias 7 years ago
commit
2e81eac6e4
5 changed files with 121 additions and 0 deletions
  1. 21 0
      __init__.py
  2. BIN
      __init__.pyc
  3. 43 0
      __openerp__.py
  4. 57 0
      invoice.py
  5. BIN
      invoice.pyc

+ 21 - 0
__init__.py

@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2013 E-MIPS (http://www.e-mips.com.ar) All Rights Reserved.
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import invoice

BIN
__init__.pyc


+ 43 - 0
__openerp__.py

@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2013 E-MIPS (http://www.e-mips.com.ar) All Rights Reserved.
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    "name": "Account Invoice interactive",
+    "version": "8.0.1.0.0",
+    "depends": ["base", "account"],
+    "author": "Eiru Software / Rodney Enciso Arias",
+    "website": "http://www.eiru.com.py",
+    "license": "GPL-3",
+    "category": "Finanzas",
+    "description": """
+        Este módulo agrega la funcionalidad del calculo interactivo de importes a medida que se
+        va completando una factura.
+    """,
+    'data': [
+        # 'sale_view.xml',
+    ],
+    'init_xml': [
+    ],
+    'test': [
+    ],
+    'installable': True,
+    'active': False,
+}

+ 57 - 0
invoice.py

@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2011-2012 E-MIPS Electronica e Informatica
+#               All Rights Reserved (<http://www.e-mips.com.ar>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from openerp import models, fields, api
+from openerp.tools.translate import _
+
+class AccountInvoice(models.Model):
+    _name = "account.invoice"
+    _inherit = "account.invoice"
+
+    amount_untaxed = fields.Float(compute='_compute_amount_all')
+    amount_tax = fields.Float(compute='_compute_amount_all')
+    amount_total = fields.Float(compute='_compute_amount_all')
+
+    @api.depends('invoice_line.price_subtotal')
+    def _compute_amount_all(self):
+        for order in self:
+            amount_tax = amount_untaxed = 0.0
+            currency = order.currency_id.with_context(date=order.date_invoice or fields.Date.context_today(order))
+            for line in order.invoice_line:
+                amount_untaxed += line.price_subtotal
+                amount_tax += (line.quantity * line.price_unit) - line.price_subtotal
+            order.amount_tax = currency.round(amount_tax)
+            order.amount_untaxed = currency.round(amount_untaxed)
+            order.amount_total = currency.round(amount_tax + amount_untaxed)
+
+class AccountInvoiceLine(models.Model):
+    _name = 'account.invoice.line'
+    _inherit = 'account.invoice.line'
+
+    price_subtotal = fields.Float(compute='_compute_price_subtotal')
+
+    @api.depends('price_unit', 'quantity', 'discount')
+    def _compute_price_subtotal(self):
+        for line in self:
+            price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
+            taxes = line.invoice_line_tax_id.compute_all(price, line.quantity, line.product_id, line.invoice_id.partner_id)
+            currency = line.invoice_id.currency_id.with_context(date=line.invoice_id.date_invoice or fields.Date.context_today(line.invoice_id))
+            line.price_subtotal = currency.round(taxes['total'])

BIN
invoice.pyc