Kaynağa Gözat

This module allows to add comision en voucher.

SEBAS 3 ay önce
işleme
e06bcba086

+ 25 - 0
__init__.py

@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 . import models
+
+
+

BIN
__init__.pyc


+ 37 - 0
__openerp__.py

@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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': 'Comision voucher',
+    'version': '2.1',
+    'category': 'Account',
+    'description': """This module allows to add comision en voucher.""",
+    'author': 'Eiru Software/Sebastian Penayo',
+    'website': 'http://www.eirusoftware.com/',
+    'depends': ['base','account'],
+    'data': [
+        'views/account_voucher_view.xml',
+        'views/res_config_settings_view.xml',
+    ],
+    'installable': True,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 25 - 0
models/__init__.py

@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 . import account_voucher
+from . import res_config_settings
+
+

BIN
models/__init__.pyc


+ 28 - 0
models/account_voucher.py

@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+
+from openerp import models, fields, api
+
+
+class AccountVoucher(models.Model):
+    _inherit = 'account.voucher'
+
+    comision = fields.Float(
+        string='Comisión',
+        compute='_compute_comision',
+        store=True
+    )
+
+    @api.model
+    def _get_porcentaje(self):
+        param = self.env['ir.config_parameter'].get_param(
+            'voucher_comision.porcentaje', '2'
+        )
+        return float(param)
+
+    @api.depends('amount')
+    def _compute_comision(self):
+        porcentaje = self._get_porcentaje()
+
+        for rec in self:
+            rec.comision = rec.amount * porcentaje / 100 if rec.amount else 0
+

BIN
models/account_voucher.pyc


+ 27 - 0
models/res_config_settings.py

@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+from openerp import models, fields, api
+
+
+class VoucherConfigSettings(models.TransientModel):
+    _inherit = 'res.config.settings'
+
+    voucher_comision_porcentaje = fields.Float(
+        string='Porcentaje Comisión'
+    )
+
+    @api.model
+    def get_default_voucher_comision_porcentaje(self, fields):
+        param = self.env['ir.config_parameter'].get_param(
+            'voucher_comision.porcentaje', '2'
+        )
+        return {
+            'voucher_comision_porcentaje': float(param)
+        }
+
+    @api.multi
+    def set_voucher_comision_porcentaje(self):
+        self.env['ir.config_parameter'].set_param(
+            'voucher_comision.porcentaje',
+            self.voucher_comision_porcentaje
+        )
+

BIN
models/res_config_settings.pyc


BIN
static/description/icon.png


+ 34 - 0
views/account_voucher_view.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- FORM -->
+        <record id="view_voucher_form_comision" model="ir.ui.view">
+            <field name="name">account.voucher.form.comision</field>
+            <field name="model">account.voucher</field>
+            <field name="inherit_id" ref="account_voucher.view_vendor_receipt_form"/>
+            <field name="arch" type="xml">
+
+                <field name="amount" position="after">
+                    <field name="comision" readonly="1"/>
+                </field>
+
+            </field>
+        </record>
+
+        <!-- TREE -->
+        <record id="view_voucher_tree_comision" model="ir.ui.view">
+            <field name="name">account.voucher.tree.comision</field>
+            <field name="model">account.voucher</field>
+            <field name="inherit_id" ref="account_voucher.view_voucher_tree"/>
+            <field name="arch" type="xml">
+
+                <field name="amount" position="after">
+                    <field name="comision"/>
+                </field>
+
+            </field>
+        </record>
+
+    </data>
+</openerp>

+ 46 - 0
views/res_config_settings_view.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!-- FORM CONFIG -->
+        <record id="view_voucher_config_settings_form" model="ir.ui.view">
+            <field name="name">voucher.config.settings.form</field>
+            <field name="model">res.config.settings</field>
+            <field name="arch" type="xml">
+                <form string="Configuración Comisión Voucher">
+
+                    <group>
+                        <field name="voucher_comision_porcentaje"/>
+                    </group>
+
+                    <footer>
+                        <button string="Guardar"
+                                type="object"
+                                name="execute"
+                                class="oe_highlight"/>
+
+                        <button string="Cancelar"
+                                special="cancel"/>
+                    </footer>
+
+                </form>
+            </field>
+        </record>
+
+        <!-- ACTION -->
+        <record id="action_voucher_config_settings" model="ir.actions.act_window">
+            <field name="name">Configuración Comisión Voucher</field>
+            <field name="res_model">res.config.settings</field>
+            <field name="view_mode">form</field>
+            <field name="target">inline</field>
+        </record>
+
+        <!-- MENU -->
+        <menuitem id="menu_voucher_config_settings"
+                  name="Comisión Voucher"
+                  parent="account.menu_finance_configuration"
+                  action="action_voucher_config_settings"
+                  sequence="50"/>
+
+    </data>
+</openerp>