[MERGE] branch merged with lp:~openerp-dev/openobject-addons/trunk-dev-addons3
authormtr <mtr@mtr>
Wed, 24 Nov 2010 05:14:42 +0000 (10:44 +0530)
committermtr <mtr@mtr>
Wed, 24 Nov 2010 05:14:42 +0000 (10:44 +0530)
bzr revid: mtr@mtr-20101124051442-x64ymf3pyb9fcy39

addons/account_sequence/__init__.py
addons/account_sequence/__openerp__.py
addons/account_sequence/account_sequence.py
addons/account_sequence/account_sequence_installer.py [new file with mode: 0644]
addons/account_sequence/account_sequence_installer_view.xml [new file with mode: 0644]
addons/sale/sale.py

index 535fb76..b670710 100644 (file)
@@ -20,5 +20,6 @@
 ##############################################################################
 
 import account_sequence
+import account_sequence_installer
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
index 966cbcb..1e3f91a 100644 (file)
     'website': 'http://www.openerp.com',
     'depends': ['account'],
     'init_xml': [],
-    'update_xml': ['account_sequence_data.xml','account_sequence.xml'],
+    'update_xml': [
+        'account_sequence_data.xml',
+        'account_sequence_installer_view.xml',
+        'account_sequence.xml'
+    ],
     'demo_xml': [],
     'installable': True,
     'active': False,
index 309bf3b..ee3afa3 100644 (file)
@@ -46,7 +46,7 @@ class account_journal(osv.osv):
     _inherit = "account.journal"
 
     _columns = {
-        'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence'),
+        'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used to maintain the internal number for the journal entries related to this journal."),
     }
 
 account_journal()
diff --git a/addons/account_sequence/account_sequence_installer.py b/addons/account_sequence/account_sequence_installer.py
new file mode 100644 (file)
index 0000000..b7b6954
--- /dev/null
@@ -0,0 +1,63 @@
+# -*- 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 osv import fields, osv
+
+class account_sequence_installer(osv.osv_memory):
+    _name = 'account.sequence.installer'
+    _inherit = 'res.config.installer'
+    
+    _columns = {
+        'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used on Journals to maintain internal number for accounting entries."),
+        }
+    
+    def _get_internal_sequence(self, cr, uid, context):
+        obj_sequence = self.pool.get('ir.sequence')
+        seq_id = obj_sequence.search(cr, uid, [('name', '=', 'Internal Sequence Journal')])
+        for seq in obj_sequence.browse(cr, uid, seq_id):
+            if seq.id:
+                return seq.id
+            return False
+     
+    def execute(self, cr, uid, ids, context):
+        if context is None:
+            context = {}
+        res =  super(account_sequence_installer, self).execute(cr, uid, ids, context=context)
+        jou_obj = self.pool.get('account.journal')
+        obj_sequence = self.pool.get('ir.sequence')
+        journal_ids = jou_obj.search(cr, uid, [('type', 'in', ['sale', 'sale_refund', 'purchase', 'purchase_refund', 'cash', 'bank', 'general', 'situation'])])
+        
+        for line in self.browse(cr, uid, ids):
+            for journal in jou_obj.browse(cr, uid, journal_ids):
+                if not journal.internal_sequence:
+                    seq_id = obj_sequence.search(cr, uid, [('name', '=', line.internal_sequence.name)])
+                    for seq in obj_sequence.browse(cr, uid, seq_id):
+                        if seq.id:
+                            jou_obj.write(cr, uid, [journal.id], {'internal_sequence': seq.id})
+        return res
+    
+    _defaults = {
+        'internal_sequence': _get_internal_sequence
+    }
+
+account_sequence_installer()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account_sequence/account_sequence_installer_view.xml b/addons/account_sequence/account_sequence_installer_view.xml
new file mode 100644 (file)
index 0000000..566dfaa
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+
+    <record id="view_account_sequence_installer" model="ir.ui.view">
+      <field name="name">account.sequence.installer.view</field>
+      <field name="model">account.sequence.installer</field>
+      <field name="type">form</field>
+      <field name="inherit_id" ref="base.res_config_installer"/>
+      <field name="arch" type="xml">
+        <data>
+            <form position="attributes">
+                <attribute name="string">Account Sequence Application Configuration</attribute>
+            </form>
+            <separator string="title" position="attributes">
+                <attribute name="string">Configure Your Account Sequence Application</attribute>
+            </separator>
+            <xpath expr='//separator[@string="vsep"]' position='attributes'>
+                <attribute name='string'></attribute>
+            </xpath>
+            <xpath expr="//label[@string='description']" position="attributes">
+                <attribute name="string">You can enhance the Account Sequence Application by installing .</attribute>
+            </xpath>
+          <group colspan="8">
+            <field name="internal_sequence"/>
+          </group>
+          <xpath expr="//button[@string='Install Modules']" position="attributes">
+              <attribute name="string">Configure</attribute>
+          </xpath>
+        </data>
+      </field>
+    </record>
+
+    <record id="action_account_seq_installer" model="ir.actions.act_window">
+      <field name="name">Account Sequence Application Configuration</field>
+      <field name="type">ir.actions.act_window</field>
+      <field name="res_model">account.sequence.installer</field>
+      <field name="view_id" ref="view_account_sequence_installer"/>
+      <field name="view_type">form</field>
+      <field name="view_mode">form</field>
+      <field name="target">new</field>
+    </record>
+
+    <record id="account_seq_installer_todo" model="ir.actions.todo">
+      <field name="action_id" ref="action_account_seq_installer"/>
+      <field name="sequence">3</field>
+            <field name="restart">always</field>
+    </record>
+
+  </data>
+</openerp>
index 29826e1..27740cb 100644 (file)
@@ -671,6 +671,8 @@ class sale_order(osv.osv):
     def action_ship_create(self, cr, uid, ids, *args):
         wf_service = netsvc.LocalService("workflow")
         picking_id = False
+        move_obj = self.pool.get('stock.move')
+        proc_obj = self.pool.get('procurement.order')
         company = self.pool.get('res.users').browse(cr, uid, uid).company_id
         for order in self.browse(cr, uid, ids, context={}):
             proc_ids = []
@@ -742,7 +744,13 @@ class sale_order(osv.osv):
                     })
                     proc_ids.append(proc_id)
                     self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
-
+                    
+                    if line.state == 'exception':
+                        for pick in order.picking_ids:
+                            for moves in pick.move_lines:
+                                if moves.state == 'cancel':
+                                    move_obj.write(cr, uid, [move_id], {'product_qty': moves.product_qty})
+                                    proc_obj.write(cr, uid, [proc_id], {'product_qty': moves.product_qty, 'product_uos_qty': moves.product_qty})
             val = {}
             for proc_id in proc_ids:
                 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)
@@ -752,7 +760,8 @@ class sale_order(osv.osv):
 
             if order.state == 'shipping_except':
                 val['state'] = 'progress'
-
+                val['shipped'] = False
+                
                 if (order.order_policy == 'manual'):
                     for line in order.order_line:
                         if (not line.invoiced) and (line.state not in ('cancel', 'draft')):