diff options
| author | KSA (Open ERP) <> | 2010-03-10 15:12:47 +0530 |
|---|---|---|
| committer | rpa (Open ERP) <rpa@tinyerp.com> | 2010-03-10 15:12:47 +0530 |
| commit | e97cd87fcd5965d510155d727d3e4e04f77f92c8 (patch) | |
| tree | 4ca6210be655a641384c7cd202f82ed450f5d6b0 /addons | |
| parent | 66812e6cae722e5af1b6b684545152068ad91a08 (diff) | |
[IMP] stock: Converted wizards into osv_memory wizard.
bzr revid: rpa@tinyerp.com-20100310094247-0gi9qlre6r82244w
Diffstat (limited to 'addons')
23 files changed, 706 insertions, 607 deletions
diff --git a/addons/stock/__init__.py b/addons/stock/__init__.py index d728efbf2fe..12a218a31be 100644 --- a/addons/stock/__init__.py +++ b/addons/stock/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -26,9 +26,9 @@ import product import report import wizard import report_stock - import stock_wizard + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/__terp__.py b/addons/stock/__terp__.py index 8081c4b6738..ba5e435fcbb 100644 --- a/addons/stock/__terp__.py +++ b/addons/stock/__terp__.py @@ -41,11 +41,16 @@ Thanks to the double entry management, the inventory controlling is powerful and "init_xml" : [], "demo_xml" : ["stock_demo.xml"], "update_xml" : [ - "stock_workflow.xml", "stock_data.xml", + "wizard/stock_inventory_set_stock_zero_view.xml", + "wizard/stock_fill_inventory_view.xml", + "wizard/stock_invoice_onshipping_view.xml", + "wizard/stock_location_product_view.xml", + "wizard/stock_inventory_line_split_view.xml", + "stock_workflow.xml", "stock_incoterms.xml", "stock_wizard.xml", - "stock_wizard_view.xml", + "stock_wizard_view.xml", "stock_view.xml", "stock_report.xml", "stock_sequence.xml", diff --git a/addons/stock/security/ir.model.access.csv b/addons/stock/security/ir.model.access.csv index eea058ebde1..581308694b8 100644 --- a/addons/stock/security/ir.model.access.csv +++ b/addons/stock/security/ir.model.access.csv @@ -22,4 +22,10 @@ "access_stock_move_consume","stock.move.consume","model_stock_move_consume","stock.group_stock_user",1,0,0,0 "access_stock_move_scrap","stock.move.scrap","model_stock_move_scrap","stock.group_stock_user",1,0,0,0 "access_stock_move_split","stock.move.split","model_stock_move_split","stock.group_stock_user",1,0,0,0 +"access_stock_move_split_lines","stock.move.split.lines","model_stock_move_split_lines","stock.group_stock_user",1,0,0,0"access_report_products_to_received_planned","report.products.to.received.planned","model_report_products_to_received_planned","stock.group_stock_user",1,0,0,0 +"access_report_delivery_products_planned","report.delivery.products.planned","model_report_delivery_products_planned","stock.group_stock_user",1,0,0,0 +"access_stock_move_track","stock.move.track","model_stock_move_track","stock.group_stock_user",1,0,0,0 +"access_stock_move_consume","stock.move.consume","model_stock_move_consume","stock.group_stock_user",1,0,0,0 +"access_stock_move_scrap","stock.move.scrap","model_stock_move_scrap","stock.group_stock_user",1,0,0,0 +"access_stock_move_split","stock.move.split","model_stock_move_split","stock.group_stock_user",1,0,0,0 "access_stock_move_split_lines","stock.move.split.lines","model_stock_move_split_lines","stock.group_stock_user",1,0,0,0
\ No newline at end of file diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 3cada5cbb6d..c112ab44d5e 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -33,7 +33,12 @@ <field name="product_uom"/> <field name="prod_lot_id"/> <field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/> - <button name="%(split_inventory_lots)d" string="Split Inventory Lines" type="action" icon="gtk-justify-fill"/> + <!-- <button name="%(split_inventory_lots)d" + string="Split Inventory Lines" type="action" + icon="gtk-justify-fill" /> --> + <button name="%(stock.action_view_stock_inventory_line_split)d" + string="Split inventory lines" + type="action" icon="gtk-justify-fill"/> </form> </field> </record> @@ -50,6 +55,7 @@ <field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/> </group> </search> + </field> </record> @@ -64,6 +70,7 @@ <field name="state"/> </tree> </field> + </record> <record id="view_inventory_form" model="ir.ui.view"> <field name="name">stock.inventory.form</field> @@ -89,11 +96,12 @@ <field name="product_qty"/> <field name="product_uom"/> <field domain="[('usage','=','internal')]" name="location_id" select="1"/> + <field name="prod_lot_id"/> <group colspan="2" col="3"> - <field name="prod_lot_id"/> - <button name="%(split_inventory_lots)d" string="Split in Production Lots" type="action" icon="gtk-justify-fill"/> - </group> - + <button name="%(stock.action_view_stock_inventory_line_split)d" + string="Split inventory lines" + type="action" icon="gtk-justify-fill"/> + </group> </form> </field> </page><page string="Posted Inventory"> @@ -106,6 +114,7 @@ <button name="action_cancel" states="cancel" string="Set to Draft" type="object" icon="gtk-cancel"/> <button name="action_cancel_inventary" states="draft" string="Cancel Inventory" type="object" icon="gtk-cancel"/> </group> + </form> </field> </record> @@ -138,6 +147,9 @@ <field name="name" select="1"/> <field name="serial" select="1"/> <field name="date" select="1"/> + <field name="active" select="1"/> + <group colspan="4"> + </group> <field name="active" /> </form> </field> @@ -524,7 +536,7 @@ <field name="auto_refresh" eval="1"/> <field name="target">new</field> <field name="context">{'action_id': active_id}</field> - </record> + </record> <record model="ir.ui.view" id="stock_picking_calendar"> <field name="name">stock.picking.calendar</field> @@ -585,7 +597,7 @@ <field name="location_id"/> <field name="location_dest_id"/> <field name="date_planned"/> - <field name="state"/> + <field name="state"/> <button name="%(stock.track_line)d" string="Split in production lots" @@ -662,6 +674,9 @@ <field name="move_type"/> </page> </notebook> + <button + name="%(stock.action_stock_invoice_onshipping)d" + string="Create Invoices" type="action" /> </form> </field> </record> @@ -726,6 +741,7 @@ <field name="min_date" select="1"/> <field name="type"/> <field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/> + </group> <notebook colspan="4"> <page string="General Information"> @@ -740,7 +756,7 @@ <field name="location_id"/> <field name="location_dest_id"/> <field name="date_planned"/> - <field name="state"/> + <field name="state"/> <button name="%(stock.track_line)d" string="Split in production lots" @@ -812,6 +828,9 @@ <field name="move_type"/> </page> </notebook> + <button + name="%(stock.action_stock_invoice_onshipping)d" + string="Create Invoice" type="action" /> </form> </field> </record> @@ -890,9 +909,6 @@ <field name="state"/> <button name="%(partial_picking)d" states="assigned" string="Validate" type="action" icon="gtk-go-forward" help="Validate Picking"/> <button name="button_cancel" states="assigned,confirmed,draft" string="Cancel" icon="gtk-cancel" help="Cancel" confirm="This operation will cancel the picking. Do you want to continue?"/> - <button name="%(wizard_invoice_onshipping)d" states="done" string="Invoice" type="action" - icon="gtk-execute" help="Create invoice" - attrs="{'invisible': [('invoice_state', '!=', '2binvoiced')]}" /> </tree> </field> </record> @@ -925,7 +941,7 @@ <field name="location_id"/> <field name="location_dest_id"/> <field name="date_planned"/> - <field name="state"/> + <field name="state"/> <button name="%(stock.track_line)d" string="Split in production lots" @@ -1110,8 +1126,8 @@ name="%(stock.move_scrap)d" string="D" type="action" icon="gtk-convert" - states="draft,waiting,confirmed,assigned" /> - </tree> + states="done,cancel" /> + </tree> <form string="Stock Moves"> <notebook colspan="4"> <page string="General Information"> @@ -1278,7 +1294,7 @@ <field name="location_id"/> <field name="location_dest_id"/> <field name="date_planned"/> - <field name="state"/> + <field name="state"/> </tree> </field> </record> @@ -1317,7 +1333,7 @@ <field name="date"/> <field name="date_planned"/> <field name="priority"/> - </group> + </group> <group colspan="2" col="4"> <separator string="Tracability" colspan="4" /> @@ -1327,7 +1343,7 @@ domain="[('product_id','=?',product_id)]" on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/> <button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill" colspan="2" /> - </group> + </group> </page> <page string="Return Picking History"> <field name="move_stock_return_history" nolabel="1"/> diff --git a/addons/stock/stock_wizard.xml b/addons/stock/stock_wizard.xml index 5db1269d42c..d562ddfbb9f 100644 --- a/addons/stock/stock_wizard.xml +++ b/addons/stock/stock_wizard.xml @@ -44,20 +44,6 @@ string="Return picking"/> <wizard - id="wizard_invoice_onshipping" - keyword="client_action_multi" - model="stock.picking" - name="stock.invoice_onshipping" - string="Create invoice"/> - - <wizard - string="Set Stock to 0" - model="stock.inventory" - name="inventory.merge.stock.zero" - keyword="client_action_multi" - id="wizard_merge_inventory_zero"/> - - <wizard string="Merge inventories" model="stock.inventory" name="inventory.merge" @@ -65,19 +51,5 @@ multi="True" id="wizard_merge_inventory"/> - <wizard - string="Fill Inventory" - model="stock.inventory" - name="stock.fill_inventory" - keyword="client_action_multi" - id="wizard_fill_inventory" - /> - - <wizard - id="location_product" - model="stock.location" - name="stock.location.products" - string="Products by Location"/> - - </data> -</openerp> + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/__init__.py b/addons/stock/wizard/__init__.py index 6a15449a151..c489f880fdf 100644 --- a/addons/stock/wizard/__init__.py +++ b/addons/stock/wizard/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## @@ -27,12 +27,13 @@ import wizard_replacement import wizard_return import wizard_split_lot_line import wizard_ups -import wizard_invoice_onshipping -import wizard_location_product -import wizard_inventory -import wizard_split_inventory_lots -import inventory_merge_zero import inventory_merge +import stock_inventory_set_stock_zero +import stock_fill_inventory +import stock_inventory_line_split +import stock_invoice_onshipping +import stock_location_product + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/inventory_merge.py b/addons/stock/wizard/inventory_merge.py index 7be8eb2b3e3..b32ad83bec3 100644 --- a/addons/stock/wizard/inventory_merge.py +++ b/addons/stock/wizard/inventory_merge.py @@ -41,6 +41,7 @@ def do_merge(self, cr, uid, data, context): invent_lines = {} if len(data['ids']) < 2: + raise wizard.except_wizard(_('Warning'), _('Please select at least two inventories.')) diff --git a/addons/stock/wizard/inventory_merge_zero.py b/addons/stock/wizard/inventory_merge_zero.py deleted file mode 100644 index 3aa2b1e9fd9..00000000000 --- a/addons/stock/wizard/inventory_merge_zero.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- 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/>. -# -############################################################################## - - -import wizard -import pooler -from tools.translate import _ - - -_form = """<?xml version="1.0"?> -<form string="Set Stock to Zero"> - <separator colspan="4" string="Set Stocks to Zero" /> - <field name="location_id"/> - <newline/> - <label colspan="4" string="Do you want to set stocks to zero ?"/> -</form> -""" -_inventory_fields = { - 'location_id' : { - 'string':'Location', - 'type':'many2one', - 'relation':'stock.location', - 'required':True - } -} - - -def do_merge(self, cr, uid, data, context): - invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory') - invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line') - prod_obj = pooler.get_pool(cr.dbname).get('product.product') - - if len(data['ids']) <> 1: - raise wizard.except_wizard(_('Warning'), - _('Please select one and only one inventory !')) - - loc = str(data['form']['location_id']) - - cr.execute('select distinct location_id,product_id from stock_inventory_line where inventory_id=%s', (data['ids'][0],)) - inv = cr.fetchall() - cr.execute('select distinct product_id from stock_move where location_dest_id=%s or location_id=%s',(loc,loc,)) - stock = cr.fetchall() - for s in stock: - if (loc,s[0]) not in inv: - p = prod_obj.browse(cr, uid, s[0]) - invent_line_obj.create(cr, uid, { - 'inventory_id': data['ids'][0], - 'location_id': loc, - 'product_id': s[0], - 'product_uom': p.uom_id.id, - 'product_qty': 0.0, - }) - return {} - - -class merge_inventory(wizard.interface): - states = { - 'init' : { - 'actions' : [], - 'result' : {'type' : 'form', - 'arch' : _form, - 'fields' : _inventory_fields, - 'state' : [('end', 'Cancel', 'gtk-cancel'), - ('merge', 'Set to Zero', 'gtk-apply', True) ]} - }, - 'merge' : { - 'actions' : [], - 'result' : {'type' : 'action', - 'action': do_merge, - 'state' : 'end'} - }, - } -merge_inventory("inventory.merge.stock.zero") - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/wizard/stock_fill_inventory.py b/addons/stock/wizard/stock_fill_inventory.py new file mode 100644 index 00000000000..246aff9eabf --- /dev/null +++ b/addons/stock/wizard/stock_fill_inventory.py @@ -0,0 +1,90 @@ +# -*- 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 +from service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + + +class stock_fill_inventory(osv.osv_memory): + _name = "stock.fill.inventory" + _description = "Fill Inventory" + _columns = { + 'location_id': fields.many2one('stock.location', 'Location', required=True), + 'recursive': fields.boolean("Include all childs for the location"), + } + + def fill_inventory(self, cr, uid, ids, context): + inventory_line_obj = self.pool.get('stock.inventory.line') + location_obj = self.pool.get('stock.location') + for fill_inventory in self.browse(cr, uid, ids): + res = {} + res_location = {} + if fill_inventory.recursive : + location_ids = location_obj.search(cr, uid, [('location_id', + 'child_of', fill_inventory.location_id.id)]) + for location in location_ids : + res = location_obj._product_get(cr, uid, location) + res_location[location] = res + else: + context.update({'compute_child': False}) + res = location_obj._product_get(cr, uid, + fill_inventory.location_id.id, context=context) + res_location[fill_inventory.location_id.id] = res + + product_ids = [] + for location in res_location.keys(): + res = res_location[location] + for product_id in res.keys(): + prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0] + uom = prod.uom_id.id + context.update({'uom': uom}) + amount = self.pool.get('stock.location')._product_get(cr, uid, + location, [product_id], context=context)[product_id] + + if(amount): + line_ids=inventory_line_obj.search(cr, uid, + [('inventory_id', '=', context['active_ids']), + ('location_id', '=', location), + ('product_id', '=', product_id), + ('product_uom', '=', uom), + ('product_qty', '=', amount)]) + if not len(line_ids): + inventory_line = {'inventory_id': context['active_ids'][0], + 'location_id': location, + 'product_id': product_id, + 'product_uom': uom, + 'product_qty': amount} + inventory_line_obj.create(cr, uid, inventory_line) + product_ids.append(product_id) + + if(len(product_ids) == 0): + raise osv.except_osv(_('Message !'), _('No product in this location.')) + return {} + +stock_fill_inventory() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/stock_fill_inventory_view.xml b/addons/stock/wizard/stock_fill_inventory_view.xml new file mode 100644 index 00000000000..5ac6732b533 --- /dev/null +++ b/addons/stock/wizard/stock_fill_inventory_view.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_stock_fill_inventory" model="ir.ui.view"> + <field name="name">Fill Inventory</field> + <field name="model">stock.fill.inventory</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Fill Inventory"> + <separator string="Fill Inventory for specific location" colspan="4" /> + <field name="location_id"/> + <newline/> + <field name="recursive"/> + <newline/> + <separator string="" colspan="4" /> + <button special="cancel" string="Cancel" /> + <button name="fill_inventory" string="Fill Inventory" type="object"/> + </form> + </field> + </record> + + <record id="action_view_stock_fill_inventory" model="ir.actions.act_window"> + <field name="name">Fill Inventory</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.fill.inventory</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + <field name="context">{'record_id' : active_id}</field> + </record> + + <record model="ir.values" id="wiki_stock_fill_inventory"> + <field name="model_id" ref="stock.model_stock_inventory" /> + <field name="object" eval="1" /> + <field name="name">Fill Inventory</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_stock_fill_inventory'))" /> + <field name="key">action</field> + <field name="model">stock.inventory</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_inventory_line_split.py b/addons/stock/wizard/stock_inventory_line_split.py new file mode 100644 index 00000000000..1723f7b3032 --- /dev/null +++ b/addons/stock/wizard/stock_inventory_line_split.py @@ -0,0 +1,105 @@ +# -*- 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 +from service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + +class stock_inventory_line_split(osv.osv_memory): + _name = "stock.inventory.line.split" + _description = "Split inventory lines" + _columns = { + 'prefix': fields.char('Prefix', size=64), + 'quantity': fields.float('Quantity per lot'), + } + + def _check_production_lot(self, cr, uid, context): + for inv_obj in self.pool.get('stock.inventory.line').browse(cr, uid, \ + context['active_ids']): + if not inv_obj.prod_lot_id: + raise osv.except_osv(_('Caution!'), _('Before splitting the \ +inventory lines, make sure the production lot is assigned to this product.')) + return + + _defaults = { + 'quantity': lambda *a: '1', + 'prefix': _check_production_lot, + } + + def split_lines(self, cr, uid, ids, context): + inv_id = context['active_id'] + inv_line_obj = self.pool.get('stock.inventory.line') + prodlot_obj = self.pool.get('stock.production.lot') + for linesplit_obj in self.browse(cr, uid, ids): + ir_sequence_obj = self.pool.get('ir.sequence') + + sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') + if not sequence: + raise wizard.except_wizard(_('Error!'), _('No production sequence defined')) + if linesplit_obj.prefix: + sequence = linesplit_obj.prefix + '/' + (sequence or '') + + inv = inv_line_obj.browse(cr, uid, [inv_id])[0] + quantity = linesplit_obj.quantity + prodlot_obj.write(cr, uid, inv.prod_lot_id.id, {'name': sequence}) + + if quantity <= 0 or inv.product_qty == 0: + return {} + + quantity_rest = inv.product_qty % quantity + + update_val = { + 'product_qty': quantity, + } + + new_line = [] + for idx in range(int(inv.product_qty // quantity)): + if idx: + current_line = inv_line_obj.copy(cr, uid, inv.id, + {'prod_lot_id': inv.prod_lot_id.id}) + new_line.append(current_line) + else: + current_line = inv.id + inv_line_obj.write(cr, uid, [current_line], update_val) + + if quantity_rest > 0: + idx = int(inv.product_qty // quantity) + update_val['product_qty'] = quantity_rest + + if idx: + current_line = inv_line_obj.copy(cr, uid, inv.id, + {'prod_lot_id': inv.prod_lot_id.id}) + new_line.append(current_line) + else: + current_line = inv_line_obj.id + inv_line_obj.write(cr, uid, [current_line], update_val) + + return {} + +stock_inventory_line_split() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/stock/wizard/stock_inventory_line_split_view.xml b/addons/stock/wizard/stock_inventory_line_split_view.xml new file mode 100644 index 00000000000..a2c9f2d065a --- /dev/null +++ b/addons/stock/wizard/stock_inventory_line_split_view.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_stock_inventory_line_split" model="ir.ui.view"> + <field name="name">Split inventory lines</field> + <field name="model">stock.inventory.line.split</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Split Inventory Line"> + <field name="prefix"/> + <newline/> + <field name="quantity"/> + <separator string="" colspan="4" /> + <label string=""/> + <button special="cancel" string="Cancel" icon="gtk-cancel" /> + <button name="split_lines" string="Ok" type="object" icon="gtk-ok"/> + </form> + </field> + </record> + + <record id="action_view_stock_inventory_line_split" model="ir.actions.act_window"> + <field name="name">Split inventory lines</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.inventory.line.split</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero.py b/addons/stock/wizard/stock_inventory_set_stock_zero.py new file mode 100644 index 00000000000..cfb1d4a0ac9 --- /dev/null +++ b/addons/stock/wizard/stock_inventory_set_stock_zero.py @@ -0,0 +1,72 @@ +# -*- 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 +from service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + + +class inventory_merge_stock_zero(osv.osv_memory): + _name = "stock.inventory.merge.stock.zero" + _description = "Set Stock to 0" + _columns = { + 'location_id': fields.many2one('stock.location', 'Location', required=True), + } + + def do_merge(self, cr, uid, ids, context): + invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory') + invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line') + prod_obj = pooler.get_pool(cr.dbname).get('product.product') + + if len(context['active_ids']) <> 1: + raise wizard.except_wizard(_('Warning'), + _('Please select one and only one inventory !')) + for id in ids: + datas = self.read(cr, uid, id) + loc = str(datas['location_id']) + + cr.execute('select distinct location_id,product_id \ + from stock_inventory_line \ + where inventory_id=%s', (context['active_ids'][0],)) + inv = cr.fetchall() + cr.execute('select distinct product_id from stock_move where \ + location_dest_id=%s or location_id=%s', (loc, loc,)) + stock = cr.fetchall() + for s in stock: + if (loc, s[0]) not in inv: + p = prod_obj.browse(cr, uid, s[0]) + invent_line_obj.create(cr, uid, { + 'inventory_id': context['active_ids'][0], + 'location_id': loc, + 'product_id': s[0], + 'product_uom': p.uom_id.id, + 'product_qty': 0.0, + }) + return {} + +inventory_merge_stock_zero() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml new file mode 100644 index 00000000000..2948b3005ea --- /dev/null +++ b/addons/stock/wizard/stock_inventory_set_stock_zero_view.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_inventory_merge_stock_zero" model="ir.ui.view"> + <field name="name">Set Stock to Zero</field> + <field name="model">stock.inventory.merge.stock.zero</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Set Stock to Zero"> + <separator string="Set Stocks to Zero" colspan="4" /> + <field name="location_id"/> + <newline/> + <label colspan="4" string="Do you want to set stocks to zero ?"/> + <separator string="" colspan="4" /> + <button special="cancel" string="Cancel" /> + <button name="do_merge" string="Set Stock to Zero" type="object"/> + </form> + </field> + </record> + + <record id="action_view_inventory_merge_stock_zero" model="ir.actions.act_window"> + <field name="name">Set Stock to Zero</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.inventory.merge.stock.zero</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + <field name="context">{'record_id' : active_id}</field> + </record> + + <record model="ir.values" id="wiki_merge_stock_zero"> + <field name="model_id" ref="stock.model_stock_inventory" /> + <field name="object" eval="1" /> + <field name="name">Set Stock to Zero</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_inventory_merge_stock_zero'))" /> + <field name="key">action</field> + <field name="model">stock.inventory</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py new file mode 100644 index 00000000000..82043fc0532 --- /dev/null +++ b/addons/stock/wizard/stock_invoice_onshipping.py @@ -0,0 +1,111 @@ +# -*- 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 +from service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + +class stock_invoice_onshipping(osv.osv_memory): + _name = "stock.invoice.onshipping" + _description = "Stock Invoice Onshipping" + _columns = { + 'journal_id': fields.many2one('account.journal', 'Destination Journal', required=True), + 'group': fields.boolean("Group by partner"), + 'type': fields.selection([('out_invoice', 'Customer Invoice'), + ('in_invoice', 'Supplier Invoice'), + ('out_refund', 'Customer Refund'), + ('in_refund', 'Supplier Refund')] , 'Type', required=True), + 'invoice_date': fields.date('Invoiced date'), + } + + def _get_type(self, cr, uid, context): + picking_obj = self.pool.get('stock.picking') + usage = 'customer' + pick = picking_obj.browse(cr, uid, context['active_id']) + if pick.invoice_state == 'invoiced': + raise osv.except_osv(_('UserError'), _('Invoice is already created.')) + if pick.invoice_state == 'none': + raise osv.except_osv(_('UserError'), _('Invoice cannot be created from Picking.')) + if pick.move_lines: + usage = pick.move_lines[0].location_id.usage + + if pick.type == 'out' and usage == 'supplier': + type = 'in_refund' + elif pick.type == 'out' and usage == 'customer': + type = 'out_invoice' + elif pick.type == 'in' and usage == 'supplier': + type = 'in_invoice' + elif pick.type == 'in' and usage == 'customer': + type = 'out_refund' + else: + type = 'out_invoice' + return type + + _defaults = { + 'type': _get_type, + } + + def create_invoice(self, cr, uid, ids, context): + result = [] + for onshipdata_obj in self.read(cr, uid, ids, ['journal_id', 'group', 'type', 'invoice_date']): + if context.get('new_picking', False): + onshipdata_obj[id] = onshipdata_obj.new_picking + onshipdata_obj[ids] = onshipdata_obj.new_picking + + picking_obj = self.pool.get('stock.picking') + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + + type = onshipdata_obj['type'] + context['date_inv'] = onshipdata_obj['invoice_date'] + res = picking_obj.action_invoice_create(cr, uid,context['active_ids'], + journal_id = onshipdata_obj['journal_id'], + group=onshipdata_obj['group'], + type=type, + context=context) + invoice_ids = res.values() + if not invoice_ids: + raise osv.except_osv(_('Error'), _('Invoice is not created')) + + if type == 'out_invoice': + xml_id = 'action_invoice_tree1' + elif type == 'in_invoice': + xml_id = 'action_invoice_tree2' + elif type == 'out_refund': + xml_id = 'action_invoice_tree3' + else: + xml_id = 'action_invoice_tree4' + + result = mod_obj._get_id(cr, uid, 'account', xml_id) + id = mod_obj.read(cr, uid, result, ['res_id']) + result = act_obj.read(cr, uid, id['res_id']) + result['res_id'] = invoice_ids + return result + +stock_invoice_onshipping() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/stock/wizard/stock_invoice_onshipping_view.xml b/addons/stock/wizard/stock_invoice_onshipping_view.xml new file mode 100644 index 00000000000..c4bec603120 --- /dev/null +++ b/addons/stock/wizard/stock_invoice_onshipping_view.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_stock_invoice_onshipping" model="ir.ui.view"> + <field name="name">Stock Invoice Onshipping</field> + <field name="model">stock.invoice.onshipping</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create invoices"> + <separator colspan="4" string="Create invoices" /> + <field name="journal_id"/> + <newline/> + <field name="group"/> + <newline/> + <field name="type"/> + <newline/> + <field name="invoice_date" /> + <separator string="" colspan="4" /> + <button special="cancel" string="Cancel" /> + <button name="create_invoice" string="Create Invoices" type="object"/> + </form> + </field> + </record> + + <record id="action_stock_invoice_onshipping" model="ir.actions.act_window"> + <field name="name">Create Invoice</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.invoice.onshipping</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + <field name="context">{'record_id' : active_id}</field> + </record> + + <record model="ir.values" id="stock_stock_invoice_onshipping"> + <field name="model_id" ref="stock.model_stock_picking" /> + <field name="object" eval="1" /> + <field name="name">Create Invoice</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_stock_invoice_onshipping'))" /> + <field name="key">action</field> + <field name="model">stock.picking</field> + </record> + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_location_product.py b/addons/stock/wizard/stock_location_product.py new file mode 100755 index 00000000000..44f6cb4dc7f --- /dev/null +++ b/addons/stock/wizard/stock_location_product.py @@ -0,0 +1,59 @@ +# -*- 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 +from service import web_services +from tools.misc import UpdateableStr, UpdateableDict +from tools.translate import _ +import netsvc +import pooler +import time +import wizard + +class stock_location_product(osv.osv_memory): + _name = "stock.location.product" + _description = "Products by Location" + _columns = { + 'from_date': fields.datetime('From'), + 'to_date': fields.datetime('To'), + } + + def action_open_window(self, cr, uid, ids, context): + mod_obj = self.pool.get('ir.model.data') + for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date']): + result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view') + id = mod_obj.read(cr, uid, result, ['res_id']) + return { + 'name': 'product', + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'product.product', + 'type': 'ir.actions.act_window', + 'context': {'location': context['active_ids'][0], + 'from_date': location_obj['from_date'], + 'to_date': location_obj['to_date']}, + 'domain': [('type', '<>', 'service')], + 'search_view_id': id['res_id'] + } + +stock_location_product() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/stock_location_product_view.xml b/addons/stock/wizard/stock_location_product_view.xml new file mode 100644 index 00000000000..5d54ee874aa --- /dev/null +++ b/addons/stock/wizard/stock_location_product_view.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_stock_location_product" model="ir.ui.view"> + <field name="name">Products by Location</field> + <field name="model">stock.location.product</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="View Stock of Products"> + <separator string="Stock Location Analysis" colspan="4"/> + <field name="from_date" colspan="4"/> + <newline/> + <field name="to_date" colspan="4"/> + <newline/> + <label string=""/> + <label string="(Keep empty to open the current situation. Adjust HH:MM:SS to 00:00:00 to filter all resources of the day for the 'From' date and 23:59:59 for the 'To' date)" align="0.0" colspan="3"/> + <separator string="" colspan="4" /> + <label string=""/> + <button special="cancel" string="Cancel" icon="gtk-cancel" /> + <button name="action_open_window" string="Open Product" type="object" icon="gtk-ok"/> + </form> + </field> + </record> + + <record id="action_view_stock_location_product" model="ir.actions.act_window"> + <field name="name">Products by Location</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">stock.location.product</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + <field name="context">{'record_id' : active_id}</field> + </record> + + <record model="ir.values" id="stock_location_product"> + <field name="model_id" ref="stock.model_stock_location" /> + <field name="object" eval="1" /> + <field name="name">Products by Location</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_stock_location_product'))" /> + <field name="key">action</field> + <field name="model">stock.location</field> + </record> + </data> +</openerp>
\ No newline at end of file diff --git a/addons/stock/wizard/stock_traceability.py b/addons/stock/wizard/stock_traceability.py index 58cc26a3224..3fc65ff74c0 100644 --- a/addons/stock/wizard/stock_traceability.py +++ b/addons/stock/wizard/stock_traceability.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # 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/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## diff --git a/addons/stock/wizard/wizard_inventory.py b/addons/stock/wizard/wizard_inventory.py deleted file mode 100644 index 42345353866..00000000000 --- a/addons/stock/wizard/wizard_inventory.py +++ /dev/null @@ -1,111 +0,0 @@ -# -*- 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/>. -# -############################################################################## - -import time -import wizard -import ir -import pooler -from osv.osv import except_osv -from osv import fields,osv -import netsvc -from tools.translate import _ - -inventory_form = """<?xml version="1.0"?> -<form string="Fill Inventory"> - <separator colspan="4" string="Fill Inventory for specific location" /> - <field name="location_id"/> - <newline/> - <field name="recursive"/> - <newline/> - -</form> -""" - -inventory_fields = { - 'location_id' : { - 'string':'Location', - 'type':'many2one', - 'relation':'stock.location', - 'required':True - }, - 'recursive' : {'string':'Include all childs for the location', 'type':'boolean'} -} - - - -def _fill_inventory(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - inventory_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line') - location_obj = pooler.get_pool(cr.dbname).get('stock.location') - res={} - res_location={} - if data['form']['recursive'] : - location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', [data['form']['location_id']])]) - for location in location_ids : - res=location_obj._product_get(cr, uid, location) - res_location[location]=res - else: - context.update({'compute_child':False}) - res=location_obj._product_get(cr, uid, data['form']['location_id'],context=context) - res_location[data['form']['location_id']]=res - - product_ids=[] - for location in res_location.keys(): - res=res_location[location] - for product_id in res.keys(): - #product_ids.append(product_id) - prod = pool.get('product.product').browse(cr, uid, [product_id])[0] - uom = prod.uom_id.id - context.update({'uom': uom}) - amount=pool.get('stock.location')._product_get(cr, uid, location, [product_id], context=context)[product_id] - - if(amount): - line_ids=inventory_line_obj.search(cr,uid,[('inventory_id','=',data['id']),('location_id','=',location),('product_id','=',product_id),('product_uom','=',uom),('product_qty','=',amount)]) - if not len(line_ids): - inventory_line={'inventory_id':data['id'],'location_id':location,'product_id':product_id,'product_uom':uom,'product_qty':amount} - inventory_line_obj.create(cr, uid, inventory_line) - product_ids.append(product_id) - - if(len(product_ids)==0): - raise wizard.except_wizard(_('Message !'), _('No product in this location.')) - return {} - - - -class fill_inventory(wizard.interface): - states = { - 'init' : { - 'actions' : [], - 'result' : {'type' : 'form', - 'arch' : inventory_form, - 'fields' : inventory_fields, - 'state' : [('end', 'Cancel', 'gtk-cancel'),('fill_inventory', 'Fill Inventory', 'gtk-apply', True) ]} - }, - 'fill_inventory' : { - 'actions' : [], - 'result' : {'type' : 'action', 'action': _fill_inventory, 'state' : 'end'} - }, - } -fill_inventory("stock.fill_inventory") - - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/wizard_invoice_onshipping.py b/addons/stock/wizard/wizard_invoice_onshipping.py deleted file mode 100644 index 22cdbc97e70..00000000000 --- a/addons/stock/wizard/wizard_invoice_onshipping.py +++ /dev/null @@ -1,167 +0,0 @@ -# -*- 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/>. -# -############################################################################## - -import wizard -import pooler -from tools.translate import _ - -invoice_form = """<?xml version="1.0"?> -<form string="Create invoices"> - <separator colspan="4" string="Create invoices" /> - <field name="journal_id"/> - <newline/> - <field name="group"/> - <newline/> - <field name="type"/> - <newline/> - <field name="invoice_date" /> -</form> -""" - -invoice_fields = { - 'journal_id': { - 'string': 'Destination Journal', - 'type': 'many2one', - 'relation': 'account.journal', - 'required': True - }, - 'group': { - 'string': 'Group by partner', - 'type': 'boolean' - }, - 'type': { - 'string': 'Type', - 'type': 'selection', - 'selection': [], - 'required': True - }, - 'invoice_date': {'string': 'Invoiced date', 'type':'date' } -} - - -def _get_type(obj, cr, uid, data, context): - picking_obj = pooler.get_pool(cr.dbname).get('stock.picking') - usage = 'customer' - pick = picking_obj.browse(cr, uid, data['id'], context) - if pick.invoice_state == 'invoiced': - raise wizard.except_wizard(_('UserError'), _('Invoice is already created.')) - if pick.invoice_state == 'none': - raise wizard.except_wizard(_('UserError'), _('Invoice cannot be created from Picking.')) - - if pick.move_lines: - usage = pick.move_lines[0].location_id.usage - - if pick.type =='out': - invoice_fields['type']['selection'] = [ - ('out_invoice', 'Customer Invoice'), - ('in_refund', 'Supplier Refund'), - ] - elif pick.type =='in': - invoice_fields['type']['selection'] = [ - ('in_invoice', 'Supplier Invoice'), - ('out_refund', 'Customer Refund'), - ] - else: - invoice_fields['type']['selection']=[ - ('out_invoice', 'Customer Invoice'), - ('in_invoice', 'Supplier Invoice'), - ('out_refund', 'Customer Refund'), - ('in_refund', 'Supplier Refund'), - ] - - if pick.type == 'out' and usage == 'supplier': - type = 'in_refund' - elif pick.type == 'out' and usage == 'customer': - type = 'out_invoice' - elif pick.type == 'in' and usage == 'supplier': - type = 'in_invoice' - elif pick.type == 'in' and usage == 'customer': - type = 'out_refund' - else: - type = 'out_invoice' - return {'type': type} - - -def _create_invoice(obj, cr, uid, data, context): - if data['form'].get('new_picking', False): - data['id'] = data['form']['new_picking'] - data['ids'] = [data['form']['new_picking']] - pool = pooler.get_pool(cr.dbname) - picking_obj = pooler.get_pool(cr.dbname).get('stock.picking') - mod_obj = pool.get('ir.model.data') - act_obj = pool.get('ir.actions.act_window') - - type = data['form']['type'] - - context['date_inv'] = data['form']['invoice_date'] - res = picking_obj.action_invoice_create(cr, uid, data['ids'], - journal_id = data['form']['journal_id'], group=data['form']['group'], - type=type, context= context) - - invoice_ids = res.values() - if not invoice_ids: - raise wizard.except_wizard(_('Error'), _('Invoice is not created')) - - if type == 'out_invoice': - xml_id = 'action_invoice_tree1' - elif type == 'in_invoice': - xml_id = 'action_invoice_tree2' - elif type == 'out_refund': - xml_id = 'action_invoice_tree3' - else: - xml_id = 'action_invoice_tree4' - - result = mod_obj._get_id(cr, uid, 'account', xml_id) - id = mod_obj.read(cr, uid, result, ['res_id']) - result = act_obj.read(cr, uid, id['res_id']) - result['res_id'] = invoice_ids - return result - - -class make_invoice_onshipping(wizard.interface): - states = { - 'init': { - 'actions': [_get_type], - 'result': { - 'type': 'form', - 'arch': invoice_form, - 'fields': invoice_fields, - 'state': [ - ('end', 'Cancel', 'gtk-cancel'), - ('create_invoice', 'Create invoice', 'gtk-apply', True) - ] - } - }, - 'create_invoice': { - 'actions': [], - 'result': { - 'type': 'action', - 'action': _create_invoice, - 'state': 'end' - } - }, - } - -make_invoice_onshipping("stock.invoice_onshipping") - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/wizard/wizard_location_product.py b/addons/stock/wizard/wizard_location_product.py deleted file mode 100755 index c423c426832..00000000000 --- a/addons/stock/wizard/wizard_location_product.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- 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/>. -# -############################################################################## - -import wizard -import pooler -import time - -def _action_open_window(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - mod_obj = pool.get('ir.model.data') - result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view') - id = mod_obj.read(cr, uid, result, ['res_id']) - return { - 'name': False, - 'view_type': 'form', - "view_mode": 'tree,form', - 'res_model': 'product.product', - 'type': 'ir.actions.act_window', - 'context':{'location': data['ids'][0],'from_date':data['form']['from_date'],'to_date':data['form']['to_date']}, - 'domain':[('type','<>','service')], - 'search_view_id': id['res_id'] - } - - -class product_by_location(wizard.interface): - form1 = '''<?xml version="1.0"?> - <form string="View Stock of Products"> - <separator string="Stock Location Analysis" colspan="4"/> - <field name="from_date"/> - <newline/> - <field name="to_date"/> - <newline/> - <label string=""/> - <label string="(Keep empty to open the current situation. Adjust HH:MM:SS to 00:00:00 to filter all resources of the day for the 'From' date and 23:59:59 for the 'To' date)" align="0.0" colspan="3"/> - </form>''' - form1_fields = { - 'from_date': { - 'string': 'From', - 'type': 'datetime', - }, - 'to_date': { - 'string': 'To', - 'type': 'datetime', - }, - } - - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel', 'gtk-cancel'),('open', 'Open Products', 'gtk-apply', True)]} - }, - 'open': { - 'actions': [], - 'result': {'type': 'action', 'action': _action_open_window, 'state':'end'} - } - } -product_by_location('stock.location.products') -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/wizard_split_inventory_lots.py b/addons/stock/wizard/wizard_split_inventory_lots.py deleted file mode 100644 index 92963f0b145..00000000000 --- a/addons/stock/wizard/wizard_split_inventory_lots.py +++ /dev/null @@ -1,98 +0,0 @@ -import wizard -import netsvc -import pooler - -import time -from osv import osv -from tools.translate import _ - -inv_form = '''<?xml version="1.0"?> -<form string="Split Inventory Line"> - <field name="prefix"/> - <newline/> - <field name="quantity"/> -</form> -''' -inv_fields = { - 'prefix': { - 'string': 'Prefix', - 'type': 'char', - 'size': 64, - }, - 'quantity': { - 'string': 'Quantity per lot', - 'type': 'float', - 'default': 1, - } -} - -def _check_production_lot(self, cr, uid, data, context): - pool = pooler.get_pool(cr.dbname) - inv_obj = pool.get('stock.inventory.line').browse(cr, uid, data['id']) - if not inv_obj.prod_lot_id: - raise wizard.except_wizard(_('Caution!'), _('Before splitting the inventory lines, make sure the production lot is assigned to this product.')) - return data['form'] - -def _split_lines(self, cr, uid, data, context): - inv_id = data['id'] - - pool = pooler.get_pool(cr.dbname) - inv_line_obj = pool.get('stock.inventory.line') - prodlot_obj = pool.get('stock.production.lot') - - ir_sequence_obj = pool.get('ir.sequence') - - sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') - if not sequence: - raise wizard.except_wizard(_('Error!'), _('No production sequence defined')) - if data['form']['prefix']: - sequence=data['form']['prefix']+'/'+(sequence or '') - - inv = inv_line_obj.browse(cr, uid, [inv_id])[0] - quantity=data['form']['quantity'] - prodlot_obj.write(cr, uid, inv.prod_lot_id.id, {'name':sequence}) - - if quantity <= 0 or inv.product_qty == 0: - return {} - - quantity_rest = inv.product_qty%quantity - - update_val = { - 'product_qty': quantity, - } - - new_line = [] - for idx in range(int(inv.product_qty//quantity)): - if idx: - current_line = inv_line_obj.copy(cr, uid, inv.id, {'prod_lot_id': inv.prod_lot_id.id}) - new_line.append(current_line) - else: - current_line = inv.id - inv_line_obj.write(cr, uid, [current_line], update_val) - - if quantity_rest > 0: - idx = int(inv.product_qty//quantity) - update_val['product_qty']=quantity_rest - - if idx: - current_line = inv_line_obj.copy(cr, uid, inv.id, {'prod_lot_id': inv.prod_lot_id.id}) - new_line.append(current_line) - else: - current_line = inv.id - inv_line_obj.write(cr, uid, [current_line], update_val) - - return {} - -class wizard_split_inventory_lots(wizard.interface): - states = { - 'init': { - 'actions': [_check_production_lot], - 'result': {'type': 'form', 'arch': inv_form, 'fields': inv_fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('split', 'Ok', 'gtk-apply', True)]}, - }, - 'split': { - 'actions': [_split_lines], - 'result': {'type':'state', 'state':'end'} - } - } - -wizard_split_inventory_lots('stock.inventory.line.split')
\ No newline at end of file |
