diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 2782f822149..591f65cf925 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -700,7 +700,7 @@ class pos_order(osv.osv): picking_id = picking_obj.create(cr, uid, { 'origin': order.name, 'partner_id': addr.get('delivery',False), - 'type': 'out', + 'picking_type_id': self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context).id, 'company_id': order.company_id.id, 'move_type': 'direct', 'note': order.note or "", diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py index eeba6cab676..fac55c593e7 100644 --- a/addons/point_of_sale/wizard/pos_return.py +++ b/addons/point_of_sale/wizard/pos_return.py @@ -213,7 +213,7 @@ class add_product(osv.osv_memory): 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', - 'type':'out', + 'picking_type_id': self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'picking_type_out', context=context).id, 'date':date_cur }) stock_move_obj.create(cr, uid, { diff --git a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml index 99e5fc41401..2d95eb89d71 100644 --- a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml +++ b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml @@ -14,8 +14,7 @@ !record {model: product.product, id: product_product_hrmanger0}: categ_id: product.product_category_6 mes_type: fixed - name: HR Manger - procure_method: make_to_stock + name: HR Manager standard_price: 1.0 supply_method: buy type: service diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 79df9f31103..8efacf7f75e 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -150,6 +150,10 @@ class purchase_order(osv.osv): limit=1) return res and res[0] or False + def _get_picking_in(self, cr, uid, context=None): + obj_data = self.pool.get('ir.model.data') + return obj_data.get_object_reference(cr, uid, 'stock','picking_type_in')[1] + STATE_SELECTION = [ ('draft', 'Draft PO'), ('sent', 'RFQ Sent'), @@ -230,6 +234,7 @@ class purchase_order(osv.osv): 'journal_id': fields.many2one('account.journal', 'Journal'), 'bid_date': fields.date('Bid Received On', readonly=True, help="Date on which the bid was received"), 'bid_validity': fields.date('Bid Valid Until', help="Date on which the bid expired"), + 'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="This will determine picking type of incoming shipment"), } _defaults = { 'date_order': fields.date.context_today, @@ -241,7 +246,8 @@ class purchase_order(osv.osv): 'pricelist_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').browse(cr, uid, context['partner_id']).property_product_pricelist_purchase.id, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.order', context=c), 'journal_id': _get_journal, - 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id + 'currency_id': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id, + 'picking_type_id': _get_picking_in, } _sql_constraints = [ ('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'), @@ -380,6 +386,8 @@ class purchase_order(osv.osv): ''' This function returns an action that display existing picking orders of given purchase order ids. ''' + if context is None: + context = {} mod_obj = self.pool.get('ir.model.data') pick_ids = [] for po in self.browse(cr, uid, ids, context=context): diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index e3af7bd6243..973757770c4 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -198,6 +198,7 @@ + diff --git a/addons/purchase/test/average_price.yml b/addons/purchase/test/average_price.yml index 0fa2dfb0a4f..79bae838f7e 100644 --- a/addons/purchase/test/average_price.yml +++ b/addons/purchase/test/average_price.yml @@ -55,10 +55,9 @@ - Process the reception of purchase order 1 - - !python {model: stock.partial.picking}: | + !python {model: stock.picking}: | pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_average1")).picking_ids - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]}) - self.do_partial(cr, uid, [partial_id]) + self.do_partial(cr, uid, [pick_ids[0].id]) - Check the standard price of the product (average icecream). - @@ -69,10 +68,9 @@ - Process the reception of purchase order 2 - - !python {model: stock.partial.picking}: | + !python {model: stock.picking}: | pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_average2")).picking_ids - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]}) - self.do_partial(cr, uid, [partial_id]) + self.do_partial(cr, uid, [pick_ids[0].id]) - Check the standard price - @@ -82,7 +80,7 @@ Create picking to send some goods - !record {model: stock.picking, id: outgoing_average_shipment}: - type: out + picking_type_id: stock.picking_type_out - Create move for picking - @@ -91,18 +89,12 @@ product_id: product_average_icecream product_uom: product.product_uom_kgm product_qty: 20.0 - type: out - - I assign this outgoing shipment + I assign this outgoing shipment and process the delivery - !python {model: stock.picking}: | self.action_assign(cr, uid, [ref("outgoing_average_shipment")]) -- - Process the delivery of the outgoing shipment -- - !python {model: stock.partial.picking}: | - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_average_shipment")], 'default_type':'out'}) - self.do_partial(cr, uid, [partial_id]) + self.do_partial(cr, uid, [ref("outgoing_average_shipment")]) - Check the standard price (60 * 10 + 30 * 80) / 40 = 75.0 did not change - @@ -129,10 +121,9 @@ - Process the reception of purchase order 3 in grams - - !python {model: stock.partial.picking}: | + !python {model: stock.picking}: | pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_average3")).picking_ids - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]}) - self.do_partial(cr, uid, [partial_id]) + self.do_partial(cr, uid, [pick_ids[0].id]) - Check price is (75.0*20 + 500) / 20.5 = 97.56097561 - diff --git a/addons/sale/sale.py b/addons/sale/sale.py index b55fccc8984..6535ed7bc6d 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -658,7 +658,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, 'partner_id': order.partner_shipping_id.id + 'name': order.name, 'partner_id': order.partner_shipping_id.id, 'move_type': order.picking_policy }, context=context) order.write({'procurement_group_id': group_id}, context=context) for line in order.order_line: @@ -1082,4 +1082,4 @@ class procurement_order(osv.osv): _defaults = { 'invoice_state': 'none', } - + \ No newline at end of file diff --git a/addons/sale_stock/__init__.py b/addons/sale_stock/__init__.py index 9c74739d4c9..72b3d5672d5 100644 --- a/addons/sale_stock/__init__.py +++ b/addons/sale_stock/__init__.py @@ -20,9 +20,7 @@ ############################################################################## import sale_stock -import stock import report import company import res_config -import wizard diff --git a/addons/sale_stock/__openerp__.py b/addons/sale_stock/__openerp__.py index b1686bebb20..059c5a59c1d 100644 --- a/addons/sale_stock/__openerp__.py +++ b/addons/sale_stock/__openerp__.py @@ -51,7 +51,6 @@ You can choose flexible invoicing methods: 'security/sale_stock_security.xml', 'security/ir.model.access.csv', 'company_view.xml', - 'wizard/stock_invoice_onshipping_view.xml', 'sale_stock_view.xml', 'sale_stock_workflow.xml', 'stock_view.xml', diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 3163365ffc0..015347449ae 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -61,7 +61,14 @@ class sale_order(osv.osv): if move.procurement_id and move.procurement_id.sale_line_id: res.add(move.procurement_id.sale_line_id.order_id.id) return list(res) - + + def _get_orders_procurements(self, cr, uid, ids, context=None): + res = set() + for proc in self.pool.get('procurement.order').browse(cr, uid, ids, context=context): + if proc.sale_line_id: + res.add(proc.sale_line_id.order_id.id) + return list(res) + def _get_picking_ids(self, cr, uid, ids, name, args, context=None): res = {} for sale in self.browse(cr, uid, ids, context=context): @@ -107,7 +114,10 @@ class sale_order(osv.osv): ('prepaid', 'Before Delivery'), ], 'Create Invoice', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, help="""On demand: A draft invoice can be created from the sales order when needed. \nOn delivery order: A draft invoice can be created from the delivery order when the products have been delivered. \nBefore delivery: A draft invoice is created from the sales order and must be paid before the products can be delivered."""), - 'shipped': fields.function(_get_shipped, string='Delivered', type='boolean', store={'stock.move': (_get_orders, ['state'], 10)}), + 'shipped': fields.function(_get_shipped, string='Delivered', type='boolean', store={ + 'stock.move': (_get_orders, ['state'], 10), + 'procurement.order': (_get_orders_procurements, ['state'], 10) + }), 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True), 'picking_ids': fields.function(_get_picking_ids, method=True, type='one2many', relation='stock.picking', string='Picking associated to this sale'), } @@ -223,7 +233,7 @@ class sale_order(osv.osv): self.pool.get('sale.order.line').write(cr, uid, write_done_ids, {'state': 'done'}) if write_cancel_ids: self.pool.get('sale.order.line').write(cr, uid, write_cancel_ids, {'state': 'exception'}) - + if mode == 'finished': return finished elif mode == 'canceled': @@ -265,7 +275,7 @@ class sale_order(osv.osv): class sale_order_line(osv.osv): _inherit = 'sale.order.line' - + def _number_packages(self, cr, uid, ids, field_name, arg, context=None): res = {} for line in self.browse(cr, uid, ids, context=context): diff --git a/addons/sale_stock/sale_stock_view.xml b/addons/sale_stock/sale_stock_view.xml index 03731bd737c..9e14ce46ce1 100644 --- a/addons/sale_stock/sale_stock_view.xml +++ b/addons/sale_stock/sale_stock_view.xml @@ -104,21 +104,7 @@ groups="sale.group_delivery_invoice_address" /> - - stock.picking.form.inherit - stock.picking - - - -