From c932b34e11fbf3346d54b5c962837cefb55649eb Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 25 Jul 2013 16:43:35 +0200 Subject: [PATCH] [WIP] Remove stock_journal, change name and origin of created procurement, remove some remaining picking in/out, add sequence on dropship bzr revid: jco@openerp.com-20130725144335-l48yws3wbqxmstxc --- .../claim_delivery_data.xml | 2 +- .../claim_delivery_view.xml | 7 +- addons/delivery/stock.py | 52 +--------- addons/procurement/procurement.py | 2 +- addons/sale/sale.py | 4 +- addons/sale_journal/sale_journal.py | 12 --- addons/stock/security/ir.model.access.csv | 2 - addons/stock/stock.py | 19 +--- addons/stock/stock_data.xml | 99 +++++++++---------- addons/stock/stock_sequence.xml | 16 +-- addons/stock/stock_view.xml | 67 ++++++------- .../stock_complex_routes.xml | 17 +++- addons/stock_location/stock_location.py | 3 - .../stock_location_demo_cpu1.xml | 3 - .../stock_location_demo_cpu3.yml | 14 +-- addons/warning/warning.py | 30 +----- 16 files changed, 111 insertions(+), 238 deletions(-) diff --git a/addons/claim_from_delivery/claim_delivery_data.xml b/addons/claim_from_delivery/claim_delivery_data.xml index 1b69087d4b8..5dabdc25931 100644 --- a/addons/claim_from_delivery/claim_delivery_data.xml +++ b/addons/claim_from_delivery/claim_delivery_data.xml @@ -4,7 +4,7 @@ Delivery Order - stock.picking.out + stock.picking diff --git a/addons/claim_from_delivery/claim_delivery_view.xml b/addons/claim_from_delivery/claim_delivery_view.xml index f9002a13543..850780644fd 100644 --- a/addons/claim_from_delivery/claim_delivery_view.xml +++ b/addons/claim_from_delivery/claim_delivery_view.xml @@ -6,17 +6,18 @@ crm.claim form - {'default_ref': 'stock.picking.out,'+str(context.get('active_id', False))} - [('ref','=','stock.picking.out,'+str(context.get('active_id',False)))] + {'default_ref': 'stock.picking,'+str(context.get('active_id', False))} + [('ref','=','stock.picking,'+str(context.get('active_id',False)))] crm.claim.from_delivery.form - stock.picking.out + stock.picking
+
diff --git a/addons/delivery/stock.py b/addons/delivery/stock.py index 95e87eb45ab..f0287c54913 100644 --- a/addons/delivery/stock.py +++ b/addons/delivery/stock.py @@ -51,6 +51,7 @@ class stock_picking(osv.osv): result[line.picking_id.id] = True return result.keys() + _columns = { 'carrier_id':fields.many2one("delivery.carrier","Carrier"), 'volume': fields.float('Volume'), @@ -184,57 +185,6 @@ class stock_move(osv.osv): 'weight_uom_id': lambda self,cr,uid,c: self._get_default_uom(cr,uid,c) } -# Redefinition of the new fields in order to update the model stock.picking.out in the orm -# FIXME: this is a temporary workaround because of a framework bug (ref: lp996816). It should be removed as soon as -# the bug is fixed -class stock_picking_out(osv.osv): - _inherit = 'stock.picking.out' - - def _cal_weight(self, cr, uid, ids, name, args, context=None): - return self.pool.get('stock.picking')._cal_weight(cr, uid, ids, name, args, context=context) - - - def _get_picking_line(self, cr, uid, ids, context=None): - return self.pool.get('stock.picking')._get_picking_line(cr, uid, ids, context=context) - - _columns = { - 'carrier_id':fields.many2one("delivery.carrier","Carrier"), - 'volume': fields.float('Volume'), - 'weight': fields.function(_cal_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_weight', - store={ - 'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 20), - 'stock.move': (_get_picking_line, ['product_id','product_qty','product_uom','product_uos_qty'], 20), - }), - 'weight_net': fields.function(_cal_weight, type='float', string='Net Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_weight', - store={ - 'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 20), - 'stock.move': (_get_picking_line, ['product_id','product_qty','product_uom','product_uos_qty'], 20), - }), - 'carrier_tracking_ref': fields.char('Carrier Tracking Ref', size=32), - 'number_of_packages': fields.integer('Number of Packages'), - } - -class stock_picking_in(osv.osv): - _inherit = 'stock.picking.in' - - def _cal_weight(self, cr, uid, ids, name, args, context=None): - return self.pool.get('stock.picking')._cal_weight(cr, uid, ids, name, args, context=context) - - def _get_picking_line(self, cr, uid, ids, context=None): - return self.pool.get('stock.picking')._get_picking_line(cr, uid, ids, context=context) - - _columns = { - 'weight': fields.function(_cal_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_weight', - store={ - 'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 20), - 'stock.move': (_get_picking_line, ['product_id','product_qty','product_uom','product_uos_qty'], 20), - }), - 'weight_net': fields.function(_cal_weight, type='float', string='Net Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_weight', - store={ - 'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 20), - 'stock.move': (_get_picking_line, ['product_id','product_qty','product_uom','product_uos_qty'], 20), - }), - } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index de4d6d953df..7ac3a919e62 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -56,7 +56,7 @@ class procurement_group(osv.osv): _description = 'Procurement Requisition' _order = "id desc" _columns = { - 'name': fields.char('Reference'), + 'name': fields.char('Reference', required=True), 'partner_id': fields.many2one('res.partner', string = 'Partner'), #Sale should pass it here 'procurement_ids': fields.many2one('procurement.order', 'group_id', 'Procurements'), } diff --git a/addons/sale/sale.py b/addons/sale/sale.py index cfad0d40621..5c8d5e2a327 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -220,6 +220,7 @@ class sale_order(osv.osv): 'payment_term': fields.many2one('account.payment.term', 'Payment Term'), 'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position'), 'company_id': fields.many2one('res.company', 'Company'), + 'procurement_group_id': fields.many2one('procurement.group', 'Procurement group'), } _defaults = { 'date_order': fields.date.context_today, @@ -667,6 +668,7 @@ class sale_order(osv.osv): for order in self.browse(cr, uid, ids, context=context): proc_ids = [] group_id = self.pool.get("procurement.group").create(cr, uid, {'name': order.name, 'sale_id': order.id}, context=context) + order.write({'procurement_group_id': group_id}, context=context) for line in order.order_line: if (line.state == 'done') or not line.product_id: continue @@ -772,8 +774,6 @@ class sale_order_line(osv.osv): 'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation and the shipping of the products to the customer", readonly=True, states={'draft': [('readonly', False)]}), 'procurement_id': fields.many2one('procurement.order', 'Procurement'), #'property_ids': fields.many2many('mrp.property', 'sale_order_line_property_rel', 'order_id', 'property_id', 'Properties', readonly=True, states={'draft': [('readonly', False)]}), - - } _order = 'order_id desc, sequence, id' _defaults = { diff --git a/addons/sale_journal/sale_journal.py b/addons/sale_journal/sale_journal.py index b6cf6d2ee56..6a9ca22490d 100644 --- a/addons/sale_journal/sale_journal.py +++ b/addons/sale_journal/sale_journal.py @@ -60,18 +60,6 @@ class picking(osv.osv): 'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoice Type', readonly=True) } -class stock_picking_in(osv.osv): - _inherit = "stock.picking" - _columns = { - 'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoice Type', readonly=True) - } - -class stock_picking_out(osv.osv): - _inherit = "stock.picking.out" - _columns = { - 'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoice Type', readonly=True) - } - class sale(osv.osv): _inherit = "sale.order" diff --git a/addons/stock/security/ir.model.access.csv b/addons/stock/security/ir.model.access.csv index 0d872948562..b0f19b502f4 100644 --- a/addons/stock/security/ir.model.access.csv +++ b/addons/stock/security/ir.model.access.csv @@ -6,8 +6,6 @@ access_stock_warehouse_user,stock.warehouse.user,model_stock_warehouse,base.grou access_stock_location__partner_manager,stock.location.partner.manager,model_stock_location,base.group_partner_manager,1,1,1,1 access_stock_location_manager,stock.location.manager,model_stock_location,stock.group_stock_manager,1,1,1,1 access_stock_location_user,stock.location.user,model_stock_location,base.group_user,1,0,0,0 -access_stock_journal_user,stock.journal.user,model_stock_journal,base.group_user,1,0,0,0 -access_stock_journal_manager,stock.journal.manager,model_stock_journal,stock.group_stock_manager,1,1,1,1 access_stock_picking_user,stock.picking user,model_stock_picking,stock.group_stock_user,1,1,1,1 access_stock_picking_manager,stock.picking manager,model_stock_picking,stock.group_stock_manager,1,1,0,0 access_stock_production_lot_manager,stock.production.lot manager,model_stock_production_lot,stock.group_stock_manager,1,0,0,0 diff --git a/addons/stock/stock.py b/addons/stock/stock.py index ec5c032b526..56593871b27 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -51,17 +51,6 @@ class stock_incoterms(osv.osv): 'active': True, } -class stock_journal(osv.osv): - _name = "stock.journal" - _description = "Inventory Journal" - _columns = { - 'name': fields.char('Stock Journal', size=32, required=True), - 'user_id': fields.many2one('res.users', 'Responsible'), - } - _defaults = { - 'user_id': lambda s, c, u, ctx: u - } - #---------------------------------------------------------- # Stock Location #---------------------------------------------------------- @@ -440,7 +429,6 @@ class stock_picking(osv.osv): 'backorder_id': fields.many2one('stock.picking', 'Back Order of', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="If this shipment was split, then this field links to the shipment which contains the already processed part.", select=True), #'type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal')], 'Shipping Type', required=True, select=True, help="Shipping type specify, goods coming in or going out."), 'note': fields.text('Notes', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}), - 'stock_journal_id': fields.many2one('stock.journal','Stock Journal', select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}), 'move_type': fields.selection([('direct', 'Partial'), ('one', 'All at once')], 'Delivery Method', required=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="It specifies goods to be deliver partially or all at once"), 'state': fields.function(_get_state, type="selection", store = {'stock.move': (_get_pickings, ['state'], 20)}, selection = [ ('draft', 'Draft'), @@ -1135,9 +1123,9 @@ class stock_move(osv.osv): This will create a procurement order """ proc_obj = self.pool.get("procurement.order") - origin = _('Procurement created by stock move %s') % move.id + origin = _('Procurement from created by rule %s') % (move.group_id and move.group_id.name or "", move.rule_id and move.rule_id.name or "") return proc_obj.create(cr, uid, { - 'name': _('MTO procurement'), + 'name': _('MTO procurement from rule %s') % move.rule_id and move.rule_id.name or "", 'origin': origin, 'company_id': move.company_id and move.company_id.id or False, 'date_planned': move.date, @@ -1331,7 +1319,7 @@ class stock_move(osv.osv): original_picking = pick_obj.browse(cr, uid, context.get('backorder_of'), context=context) new_picking_name = original_picking.name #TODO back_order_name is False currently => find why - back_order_name = sequence_obj.get(cr, uid, 'stock.picking') #TODO: Need to have sequence for every picking type + back_order_name = sequence_obj.get_by_id(cr, uid, original_picking.picking_type_id.id, 'id') #TODO: Need to have sequence for every picking type pick_obj.write(cr, uid, [original_picking.id], {'name': back_order_name}) pick = pick_obj.copy(cr, uid, original_picking.id, {'name': new_picking_name, 'move_lines': [], @@ -1347,6 +1335,7 @@ class stock_move(osv.osv): 'company_id': move.company_id and move.company_id.id or False, 'move_type': 'one', 'partner_id': move.partner_id and move.partner_id.id or False, + 'date_done': move.date_expected, #'invoice_state': move.invoice_state 'state': 'confirmed', 'group_id': move.group_id and move.group_id.id or False, diff --git a/addons/stock/stock_data.xml b/addons/stock/stock_data.xml index 9e776a69b9c..ee1556e1161 100644 --- a/addons/stock/stock_data.xml +++ b/addons/stock/stock_data.xml @@ -1,5 +1,49 @@ + + + + + + Picking in + IN + 5 + + + + + Picking out + OUT + 5 + + + + + Picking internal + INT + 5 + + + + + in + + + + + + out + + + + + internal + + + + @@ -85,9 +129,6 @@ watch your stock valuation, and track production lots upstream and downstream (b - - Delivery Orders - Output @@ -99,58 +140,6 @@ watch your stock valuation, and track production lots upstream and downstream (b - - - - - Picking in - IN - 5 - - - - - Picking out - OUT - 5 - - - - - Picking internal - INT - 5 - - - - - Picking inventory - INV - 5 - - - - - in - - - - - - out - - - - - internal - - - - inventory - - - + Picking INT diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 0c39c347791..d90d44588a7 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -570,7 +570,6 @@ - @@ -601,7 +600,7 @@ - + @@ -631,7 +630,6 @@ - @@ -660,13 +658,13 @@ - + - - + + @@ -1133,58 +1131,61 @@ - - stock.journal.filter - stock.journal + + stock.picking.type.filter + stock.picking.type - - - + + + - - Stock Journals - stock.journal + + Picking types + stock.picking.type - + - + + - - Stock Journals - stock.journal + + Picking Types + stock.picking.type -
+ - + +
- - Stock Journals - stock.journal + + Picking Types + stock.picking.type ir.actions.act_window form

- Click to create a new journal. + Click to create a new picking type.

- The stock journal system allows you to assign each stock - operation to a specific journal according to the type of - operation to perform or the worker/team that should perform the - operation. Examples of stock journals may be: quality control, - pick lists, packing, etc. + The picking type system allows you to assign each stock + operation a specific type which will alter its views accordingly. + On the picking type you could e.g. specify if packing is needed by default, + if it should show the customer. +
+ Examples are in, out, internal, packing, quality control, ...

diff --git a/addons/stock_complex_routes/stock_complex_routes.xml b/addons/stock_complex_routes/stock_complex_routes.xml index 2f39c860b13..d2360fd5bdc 100644 --- a/addons/stock_complex_routes/stock_complex_routes.xml +++ b/addons/stock_complex_routes/stock_complex_routes.xml @@ -1,10 +1,21 @@ - + + + + Dropship + DS + 5 + + + dropship + + + Drop Shipping @@ -24,6 +35,10 @@ + + Crossdock + True + Supplier → Output buy diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py index aba1c594e4f..c5ad4dbfa01 100644 --- a/addons/stock_location/stock_location.py +++ b/addons/stock_location/stock_location.py @@ -90,9 +90,6 @@ class stock_location_path(osv.osv): 'location_dest_id': rule.location_dest_id.id }) vals = {} -# TODO journal_id was to be removed? -# if route.journal_id: -# vals['stock_journal_id'] = route.journal_id.id vals['type'] = rule.picking_type if rule.location_dest_id.id<>move.location_dest_id.id: move_obj._push_apply(self, cr, uid, move.id, context) diff --git a/addons/stock_location/stock_location_demo_cpu1.xml b/addons/stock_location/stock_location_demo_cpu1.xml index 57269adc220..8a54c38f597 100644 --- a/addons/stock_location/stock_location_demo_cpu1.xml +++ b/addons/stock_location/stock_location_demo_cpu1.xml @@ -3,9 +3,6 @@ This product is configured with example of push/pull flows - - Quality Control - diff --git a/addons/stock_location/stock_location_demo_cpu3.yml b/addons/stock_location/stock_location_demo_cpu3.yml index 38d3cfe4030..52a18c4a68e 100644 --- a/addons/stock_location/stock_location_demo_cpu3.yml +++ b/addons/stock_location/stock_location_demo_cpu3.yml @@ -1,15 +1,3 @@ -- - !record {model: stock.journal, id: journal_pick}: - name: Pick List -- - !record {model: stock.journal, id: journal_pack}: - name: Packing -- - !record {model: stock.journal, id: journal_gate_a}: - name: Delivery Gate A -- - !record {model: stock.journal, id: journal_gate_b}: - name: Delivery Gate B - !record {model: stock.location, id: location_order}: name: Order Processing @@ -36,4 +24,4 @@ product_id: product.product_product_10 location_from_id: stock.stock_location_output location_dest_id: location_pack_zone - picking_type_id: stock.picking_type_internal + picking_type_id: stock.picking_type_internal \ No newline at end of file diff --git a/addons/warning/warning.py b/addons/warning/warning.py index 8e1168e5d35..b0ca4937f94 100644 --- a/addons/warning/warning.py +++ b/addons/warning/warning.py @@ -172,8 +172,8 @@ class stock_picking(osv.osv): # FIXME:(class stock_picking_in and stock_picking_out) this is a temporary workaround because of a framework bug (ref: lp:996816). # It should be removed as soon as the bug is fixed -class stock_picking_in(osv.osv): - _inherit = 'stock.picking.in' +class stock_picking(osv.osv): + _inherit = 'stock.picking' def onchange_partner_in(self, cr, uid, ids, partner_id=None, context=None): if not partner_id: @@ -198,32 +198,6 @@ class stock_picking_in(osv.osv): return {'value': result.get('value',{}), 'warning':warning} -class stock_picking_out(osv.osv): - _inherit = 'stock.picking.out' - - def onchange_partner_in(self, cr, uid, ids, partner_id=None, context=None): - if not partner_id: - return {} - partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) - warning = {} - title = False - message = False - if partner.picking_warn != 'no-message': - if partner.picking_warn == 'block': - raise osv.except_osv(_('Alert for %s!') % (partner.name), partner.picking_warn_msg) - title = _("Warning for %s") % partner.name - message = partner.picking_warn_msg - warning = { - 'title': title, - 'message': message - } - result = super(stock_picking_out, self).onchange_partner_in(cr, uid, ids, partner_id, context) - if result.get('warning',False): - warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title'] - warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message'] - - return {'value': result.get('value',{}), 'warning':warning} - class product_product(osv.osv): _inherit = 'product.product' _columns = {