Rodney Enciso Arias 8 lat temu
commit
2771a232c3
6 zmienionych plików z 144 dodań i 0 usunięć
  1. 1 0
      .gitignore
  2. 5 0
      README.md
  3. 21 0
      __init__.py
  4. 44 0
      __openerp__.py
  5. 67 0
      sale.py
  6. 6 0
      sale_view.xml

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+*.pyc

+ 5 - 0
README.md

@@ -0,0 +1,5 @@
+### Sale Order interactive  
+
+Este modulo permite que al completar una sale order(guardada o no), se calculen al vuelo los importes de las sale.order.lines y su sale.order correspondiente.  
+
+#### IMPORTANTE: Requiere Odoo 8.0

+ 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 sale

+ 44 - 0
__openerp__.py

@@ -0,0 +1,44 @@
+# -*- 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": "Sale Order interactive",
+    "version": "8.0.1.0.0",
+    "depends": ["base", "sale", "sale_stock"],
+    "author": "E-MIPS",
+    "website": "http://e-mips.com.ar",
+    "license": "GPL-3",
+    "category": "Argentina Localization",
+    "description": """
+        Este módulo agrega la funcionalidad del calculo interactivo de importes a medida que se
+        va completando una sale order.
+        Requiere Odoo 8.0
+    """,
+    'data': [
+        'sale_view.xml',
+    ],
+    'init_xml': [
+    ],
+    'test': [
+    ],
+    'installable': True,
+    'active': False,
+}

+ 67 - 0
sale.py

@@ -0,0 +1,67 @@
+# -*- 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 sale_order(models.Model):
+    _name = "sale.order"
+    _description = "Sales Order"
+    _inherit = "sale.order"
+    _order = "date_order desc, name desc"
+
+    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('order_line.price_subtotal')
+    def _compute_amount_all(self):
+        for order in self:
+            amount_tax = amount_untaxed = 0.0
+            currency = order.pricelist_id.currency_id.with_context(date=order.date_order or fields.Date.context_today(order))
+            for line in order.order_line:
+                amount_untaxed += line.price_subtotal
+                amount_tax += self._amount_line_tax(line)
+            order.amount_tax = currency.round(amount_tax)
+            order.amount_untaxed = currency.round(amount_untaxed)
+            order.amount_total = currency.round(amount_tax + amount_untaxed)
+
+sale_order()
+
+
+class sale_order_line(models.Model):
+    _name = 'sale.order.line'
+    _inherit = 'sale.order.line'
+    _description = 'Order Line'
+
+    price_subtotal = fields.Float(compute='_compute_price_subtotal')
+
+    @api.depends('price_unit', 'product_uom_qty', 'product_uos_qty', 'discount')
+    def _compute_price_subtotal(self):
+        for line in self:
+            price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
+            taxes = line.tax_id.compute_all(price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
+            currency = line.order_id.pricelist_id.currency_id.with_context(date=line.order_id.date_order or fields.Date.context_today(line.order_id))
+            line.price_subtotal = currency.round(taxes['total'])
+
+sale_order_line()
+

+ 6 - 0
sale_view.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+    </data>
+</openerp>