Ver código fonte

sale_fast_confirm

sebastian 5 anos atrás
commit
bb5b8063ce

+ 1 - 0
__init__.py

@@ -0,0 +1 @@
+import models

BIN
__init__.pyc


+ 54 - 0
__openerp__.py

@@ -0,0 +1,54 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#    
+#    Odoo, Open Source Management Solution
+#
+#    Author: Andrius Laukavičius. Copyright: JSC NOD Baltic
+#
+#    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 Fast Confirm',
+    'version': '1.2',
+    'category': 'Sale',
+    'summary': 'Auto confirm invoice, delivery orders',
+    'description': """
+	After confirming sale order, automatically creates invoice, validates it.
+    If there are delivery orders, it also confirms it too.
+	""",
+    'author': 'OERP - Adrielso Kunert - Rodney Enciso Arias',
+    'website': 'www.oerp.eu',
+    'depends': [   
+        'sale_stock',
+    ],
+    'data': [
+        #'security/ir.model.access.csv',
+        'views/sale_view.xml',
+        #'data/',        
+
+    ],
+    'demo': [
+    ],
+    'test': [
+
+    ],
+    'installable': True,
+    'application': False,
+    'auto_install': False,
+    'images': [],
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 1 - 0
models/__init__.py

@@ -0,0 +1 @@
+import sale_fast_confirm

BIN
models/__init__.pyc


+ 64 - 0
models/sale_fast_confirm.py

@@ -0,0 +1,64 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    Odoo, Open Source Management Solution
+#
+#    Author: Andrius Laukavičius. Copyright: JSC NOD Baltic
+#
+#    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, api
+from pytz import timezone
+from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
+from datetime import datetime,timedelta
+
+DATE_FORMAT = '%Y-%m-%d'
+# return datetime.now(self.get_timezone()).strftime(DATE_FORMAT)
+
+class SaleOrder(models.Model):
+    _inherit = 'sale.order'
+
+    ''' Timezone '''
+    def get_timezone(self):
+        return timezone(self._context.get('tz') or self.env.user.tz)
+
+    def _convert_str_to_datetime(self, date):
+        return datetime.strptime(date,DEFAULT_SERVER_DATETIME_FORMAT)
+
+    @api.multi
+    def order_process_now(self):
+        """
+        Confirms order and creates and validates invoice, confirms pickings.
+        """
+        for sale in self:
+            sale.action_button_confirm()
+            inv_id = sale.action_invoice_create()
+            if inv_id:
+                inv = self.env['account.invoice'].browse(inv_id)
+                date = self._convert_str_to_datetime(sale.date_order)
+                date = date.strftime(DATE_FORMAT)
+                inv.write({'date_invoice':date})
+                self.update_state()
+                inv.signal_workflow('invoice_open')
+            for picking in sale.picking_ids:
+                picking.force_assign()
+                picking.action_done()
+
+    @api.multi
+    def update_state(self):
+        for order in self:
+            order.write({'state': 'done'})
+        return True

BIN
models/sale_fast_confirm.pyc


+ 42 - 0
models/sale_fast_confirm.py~

@@ -0,0 +1,42 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    Odoo, Open Source Management Solution
+#
+#    Author: Andrius Laukavičius. Copyright: JSC NOD Baltic
+#
+#    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, api
+
+class SaleOrder(models.Model):
+    _inherit = 'sale.order'
+
+    @api.multi
+    def order_process_now(self):
+        """
+        Confirms order and creates and validates invoice, confirms pickings.
+        """
+        for sale in self:
+            # Process order
+            sale.action_button_confirm()
+            inv_id = sale.action_invoice_create()
+            if inv_id:
+                inv = self.env['account.invoice'].browse(inv_id)
+              #  inv.signal_workflow('invoice_open')
+            for picking in sale.picking_ids:
+                picking.force_assign()
+                picking.action_done()

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

@@ -0,0 +1 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

+ 16 - 0
static/description/index.html

@@ -0,0 +1,16 @@
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span12">
+            <h2 class="oe_slogan">Sale Fast Confirm</h2>
+            <h3 class="oe_slogan">Auto confirm invoice, delivery orders</h3>
+        </div>
+        <div class="oe_span6">
+            <p class="oe_mt32">
+After confirming sale order, automatically creates invoice, validates it. If there are delivery orders, it also confirms it too.
+            </p>
+            <div class="oe_centeralign oe_websiteonly">
+                <a href="http://www.oerp.eu/#trial" class="oe_button oe_big oe_tacky">Start your <span class="oe_emph">free</span> trial</a>
+            </div>
+        </div>
+    </div>
+</section>

+ 68 - 0
views/sale_view.xml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="view_order_confirm_form" model="ir.ui.view">
+            <field name="name">sale.order.form - Confirm</field>
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="sale.view_order_form"/>
+            <field name="arch" type="xml">
+
+                <!-- Confirmacion Rapida -->
+                <button name="action_button_confirm" states="sent" position="after">
+                    <button name="order_process_now" string="Procesar Venta" type="object" states="draft,sent" groups="base.group_user"/>
+                </button>
+                
+                <!-- Enviar por Mail -->
+                <button name="action_quotation_send" position="replace">
+                    <button name="action_quotation_send" string="Send by Email" type="object" states="draft" class="oe_highlight" groups="base.group_user" invisible="1"/>
+                </button>
+                <button name="action_quotation_send" states="sent,progress,manual" position="replace">
+                    <button name="action_quotation_send" string="Send by Email" type="object" groups="base.group_user" invisible="1"/>
+                </button>
+
+                <!-- Imprimir Pedido -->
+                <button name="print_quotation" states="draft" position="replace">
+                    <button name="print_quotation" string="Print" type="object" states="draft" class="oe_highlight" groups="base.group_user" invisible="1"/>
+                </button>
+                <button name="print_quotation" states="sent,progress,manual" position="replace">
+                     <button name="print_quotation" string="Print" type="object" states="sent,progress,manual" groups="base.group_user" invisible="1"/>
+                </button>
+
+                <!-- confirmar pedido -->
+                <button name="action_button_confirm" position="replace">
+                   <button name="action_button_confirm" states="draft" string="Confirm Sale" type="object" groups="base.group_user" invisible="1"/>
+                </button>
+                <button name="action_button_confirm" position="replace">
+                    <button name="action_button_confirm" states="sent" string="Confirm Sale" class="oe_highlight" type="object" groups="base.group_user" invisible="1"/>
+                </button>
+
+                <!-- cancelar pedido -->
+                <button name="invoice_cancel" position="replace">
+                    <button name="invoice_cancel" states="invoice_except" string="Cancel Order" groups="base.group_user" invisible="1"/>
+                </button>
+                <button name="cancel" position="replace">
+                    <button name="cancel" states="draft,sent" string="Cancel Quotation" groups="base.group_user" invisible="1"/>
+                </button>
+                <button name="action_cancel" position="replace">
+                    <button name="action_cancel" states="manual,progress" string="Cancel Order" type="object" groups="base.group_user" invisible="1"/>
+                </button>
+            </field>
+        </record>
+        <record id="order_process_now_action" model="ir.actions.server">
+            <field name="name">Fast Confirm</field>
+            <field name="model_id" ref="model_sale_order"/>
+            <field name="state">code</field>
+            <field name="code">
+                if context.get('active_model') == 'sale.order' and context.get('active_ids'):
+                    self.order_process_now(cr, uid, context['active_ids'], context=context)
+            </field>
+        </record>
+
+        <record id="ir_order_process_now" model="ir.values">
+            <field eval="'client_action_multi'" name="key2"/>
+            <field eval="'sale.order'" name="model"/>
+            <field name="name">Fast Confirm</field>
+            <field eval="'ir.actions.server,%d'%order_process_now_action" name="value"/>
+        </record>        
+    </data>
+</openerp>