diff options
| author | Josse Colpaert <jco@odoo.com> | 2014-09-17 22:12:51 +0200 |
|---|---|---|
| committer | Josse Colpaert <jco@odoo.com> | 2014-09-17 22:12:51 +0200 |
| commit | ccc3e7ff994c66cafab17c02cd293128e0e8d3ef (patch) | |
| tree | e0653532585d33d64e6e5615fc00cced769c37b6 /addons | |
| parent | 8aca4094af3796668c1bdcde8ead3fcab3c3e8da (diff) | |
| parent | 5aeccbd90ed9d8e627c31823b976ab31e6d35312 (diff) | |
Merge pull request #2502 from odoo-dev/8.0-wmsstaging9-jco
8.0 wmsstaging9 jco
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/delivery/stock.py | 8 | ||||
| -rw-r--r-- | addons/mrp/mrp.py | 4 | ||||
| -rw-r--r-- | addons/mrp/mrp_view.xml | 1 | ||||
| -rw-r--r-- | addons/mrp_repair/mrp_repair.py | 2 | ||||
| -rw-r--r-- | addons/product/product.py | 3 | ||||
| -rw-r--r-- | addons/product_extended/product_extended.py | 25 | ||||
| -rw-r--r-- | addons/purchase/purchase.py | 19 | ||||
| -rw-r--r-- | addons/purchase/purchase_view.xml | 3 | ||||
| -rw-r--r-- | addons/purchase/stock.py | 19 | ||||
| -rw-r--r-- | addons/sale/sale.py | 3 | ||||
| -rw-r--r-- | addons/sale/sale_view.xml | 1 | ||||
| -rw-r--r-- | addons/stock/stock.py | 9 | ||||
| -rw-r--r-- | addons/stock/stock_demo.xml | 2 | ||||
| -rw-r--r-- | addons/stock/stock_view.xml | 10 | ||||
| -rw-r--r-- | addons/stock/wizard/stock_change_product_qty.py | 3 | ||||
| -rw-r--r-- | addons/stock_account/stock.py | 2 |
16 files changed, 66 insertions, 48 deletions
diff --git a/addons/delivery/stock.py b/addons/delivery/stock.py index 8e7b5836355..6f2d2a07ca0 100644 --- a/addons/delivery/stock.py +++ b/addons/delivery/stock.py @@ -147,10 +147,6 @@ class stock_move(osv.osv): weight = weight_net = 0.00 if move.product_id.weight > 0.00: converted_qty = move.product_qty - - if move.product_uom.id <> move.product_id.uom_id.id: - converted_qty = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, move.product_id.uom_id.id) - weight = (converted_qty * move.product_id.weight) if move.product_id.weight_net > 0.00: @@ -165,11 +161,11 @@ class stock_move(osv.osv): _columns = { 'weight': fields.function(_cal_move_weight, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight', store={ - 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_qty', 'product_uom'], 20), + 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_uom_qty', 'product_uom'], 30), }), 'weight_net': fields.function(_cal_move_weight, type='float', string='Net weight', digits_compute= dp.get_precision('Stock Weight'), multi='_cal_move_weight', store={ - 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_qty', 'product_uom'], 20), + 'stock.move': (lambda self, cr, uid, ids, c=None: ids, ['product_id', 'product_uom_qty', 'product_uom'], 30), }), 'weight_uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True,readonly="1",help="Unit of Measure (Unit of Measure) is the unit of measurement for Weight",), } diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 850f8c22eda..5add8703614 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -1097,6 +1097,7 @@ class mrp_production(osv.osv): def _make_consume_line_from_data(self, cr, uid, production, product, uom_id, qty, uos_id, uos_qty, context=None): stock_move = self.pool.get('stock.move') + loc_obj = self.pool.get('stock.location') # Internal shipment is created for Stockable and Consumer Products if product.type not in ('product', 'consu'): return False @@ -1107,7 +1108,7 @@ class mrp_production(osv.osv): if production.bom_id.routing_id and production.bom_id.routing_id.location_id and production.bom_id.routing_id.location_id.id != source_location_id: source_location_id = production.bom_id.routing_id.location_id.id prev_move = True - + destination_location_id = production.product_id.property_stock_production.id move_id = stock_move.create(cr, uid, { 'name': production.name, @@ -1125,6 +1126,7 @@ class mrp_production(osv.osv): #this saves us a browse in create() 'price_unit': product.standard_price, 'origin': production.name, + 'warehouse_id': loc_obj.get_warehouse(cr, uid, production.location_src_id, context=context), }, context=context) if prev_move: diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 160bd2e0c3d..9240c369a0e 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -383,7 +383,6 @@ <field name="product_uom" on_change="onchange_uom(product_id, product_uom)" groups="product.group_uom"/> <field name="date_start"/> <field name="date_stop"/> - <field name="routing_id"/> <field name="attribute_value_ids" widget="many2many_tags"/> </tree> </field> diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index 04f4ef8b4ef..2015b11d7c2 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -519,7 +519,7 @@ class ProductChangeMixin(object): partner = self.pool.get('res.partner').browse(cr, uid, partner_id) result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner.property_account_position, product_obj.taxes_id) - result['name'] = product_obj.partner_ref + result['name'] = product_obj.display_name result['product_uom'] = product_obj.uom_id and product_obj.uom_id.id or False if not pricelist: warning = { diff --git a/addons/product/product.py b/addons/product/product.py index cc8d1affb3a..c36fb278537 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -1007,9 +1007,10 @@ class product_product(osv.osv): sellers = filter(lambda x: x.name.id == partner_id, product.seller_ids) if sellers: for s in sellers: + seller_variant = s.product_name and "%s (%s)" % (s.product_name, variant) or False mydict = { 'id': product.id, - 'name': s.product_name or name, + 'name': seller_variant or name, 'default_code': s.product_code or product.default_code, } result.append(_name_get(mydict)) diff --git a/addons/product_extended/product_extended.py b/addons/product_extended/product_extended.py index 6ed71c6873a..14383704b34 100644 --- a/addons/product_extended/product_extended.py +++ b/addons/product_extended/product_extended.py @@ -36,15 +36,15 @@ class product_product(osv.osv): testdict = {} for prod_id in ids: bom_obj = self.pool.get('mrp.bom') - bom_ids = bom_obj.search(cr, uid, [('product_id','=', prod_id), ('bom_line_ids', '!=', False)], context=context) - if bom_ids: - bom_id = bom_ids[0] + bom_id = bom_obj._bom_find(cr, uid, False, product_id = prod_id, context=context) + if bom_id: # In recursive mode, it will first compute the prices of child boms if recursive: #Search the products that are components of this bom of prod_id - boms = bom_obj.search(cr, uid, [('bom_id', '=', bom_id)], context=context) + bom = bom_obj.browse(cr, uid, bom_id, context=context) + #Call compute_price on these subproducts - prod_set = set([x.product_id.id for x in bom_obj.browse(cr, uid, boms, context=context)]) + prod_set = set([x.product_id.id for x in bom.bom_line_ids]) res = self.compute_price(cr, uid, list(prod_set), recursive=recursive, test=test, real_time_accounting = real_time_accounting, context=context) if test: testdict.update(res) @@ -63,10 +63,10 @@ class product_product(osv.osv): context={} price = 0 uom_obj = self.pool.get("product.uom") - if bom.bom_line_ids: - for sbom in bom.bom_line_ids: - my_qty = sbom.bom_line_ids and 1.0 or sbom.product_qty - price += uom_obj._compute_price(cr, uid, sbom.product_id.uom_id.id, sbom.product_id.standard_price, sbom.product_uom.id) * my_qty + tmpl_obj = self.pool.get('product.template') + for sbom in bom.bom_line_ids: + my_qty = sbom.product_qty + price += uom_obj._compute_price(cr, uid, sbom.product_id.uom_id.id, sbom.product_id.standard_price, sbom.product_uom.id) * my_qty if bom.routing_id: for wline in bom.routing_id.workcenter_lines: @@ -79,15 +79,16 @@ class product_product(osv.osv): #Convert on product UoM quantities if price > 0: price = uom_obj._compute_price(cr, uid, bom.product_uom.id, price / bom.product_qty, bom.product_id.uom_id.id) - product = self.pool.get("product.product").browse(cr, uid, bom.product_id.id, context=context) + + product = tmpl_obj.browse(cr, uid, bom.product_tmpl_id.id, context=context) if not test: if (product.valuation != "real_time" or not real_time_accounting): - self.write(cr, uid, [bom.product_id.id], {'standard_price' : price}, context=context) + tmpl_obj.write(cr, uid, [product.id], {'standard_price' : price}, context=context) else: #Call wizard function here wizard_obj = self.pool.get("stock.change.standard.price") ctx = context.copy() - ctx.update({'active_id': bom.product_id.id}) + ctx.update({'active_id': product.id, 'active_model': 'product.template'}) wiz_id = wizard_obj.create(cr, uid, {'new_price': price}, context=ctx) wizard_obj.change_price(cr, uid, [wiz_id], context=ctx) return price diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index be2803261e7..97f0861ef31 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -679,12 +679,12 @@ class purchase_order(osv.osv): def action_cancel(self, cr, uid, ids, context=None): for purchase in self.browse(cr, uid, ids, context=context): for pick in purchase.picking_ids: - if pick.state not in ('draft', 'cancel'): - raise osv.except_osv( - _('Unable to cancel the purchase order %s.') % (purchase.name), - _('First cancel all receipts related to this purchase order.')) - self.pool.get('stock.picking') \ - .signal_workflow(cr, uid, map(attrgetter('id'), purchase.picking_ids), 'button_cancel') + for move in pick.move_lines: + if pick.state == 'done': + raise osv.except_osv( + _('Unable to cancel the purchase order %s.') % (purchase.name), + _('You have already received some goods for it. ')) + self.pool.get('stock.picking').action_cancel(cr, uid, [x.id for x in purchase.picking_ids if x.state != 'cancel'], context=context) for inv in purchase.invoice_ids: if inv and inv.state not in ('cancel', 'draft'): raise osv.except_osv( @@ -692,10 +692,6 @@ class purchase_order(osv.osv): _('You must first cancel all invoices related to this purchase order.')) self.pool.get('account.invoice') \ .signal_workflow(cr, uid, map(attrgetter('id'), purchase.invoice_ids), 'invoice_cancel') - self.pool['purchase.order.line'].write(cr, uid, [l.id for l in purchase.order_line], - {'state': 'cancel'}) - self.write(cr, uid, ids, {'state': 'cancel'}) - self.set_order_line_status(cr, uid, ids, 'cancel', context=context) self.signal_workflow(cr, uid, ids, 'purchase_cancel') return True @@ -1156,6 +1152,7 @@ class purchase_order_line(osv.osv): self.write(cr, uid, ids, {'state': 'confirmed'}, context=context) return True + class procurement_rule(osv.osv): _inherit = 'procurement.rule' @@ -1287,7 +1284,7 @@ class procurement_order(osv.osv): product = prod_obj.browse(cr, uid, procurement.product_id.id, context=new_context) taxes_ids = procurement.product_id.supplier_taxes_id taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids) - name = product.partner_ref + name = product.display_name if product.description_purchase: name += '\n' + product.description_purchase diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 239bc990ff2..1ccd8af6011 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -202,8 +202,7 @@ <button name="view_picking" string="Receive Products" type="object" attrs="{'invisible': ['|', ('shipped','=',True), ('state','!=', 'approved')]}" class="oe_highlight"/> <button name="view_invoice" string="Receive Invoice" type="object" attrs="{'invisible': ['|', ('invoice_method','in', ['picking', 'manual']), '|', ('state','!=', 'approved'), ('invoiced','=',True) ]}" class="oe_highlight"/> <button name="action_cancel_draft" states="cancel,sent,confirmed" string="Set to Draft" type="object" /> - <button name="purchase_cancel" states="draft,confirmed,sent,bid" string="Cancel"/> - <button name="action_cancel" states="approved,except_picking,except_invoice" string="Cancel" type="object" /> + <button name="action_cancel" states="draft,confirmed,sent,bid,approved,except_picking,except_invoice" string="Cancel" type="object" /> <field name="state" widget="statusbar" statusbar_visible="draft,sent,bid,approved,done" statusbar_colors='{"except_picking":"red","except_invoice":"red","confirmed":"blue"}' readonly="1"/> </header> <sheet> diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 205513c90ac..977326e7511 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -139,6 +139,25 @@ class stock_picking(osv.osv): }), } + def _create_invoice_from_picking(self, cr, uid, picking, vals, context=None): + purchase_obj = self.pool.get("purchase.order") + purchase_line_obj = self.pool.get('purchase.order.line') + invoice_line_obj = self.pool.get('account.invoice.line') + invoice_id = super(stock_picking, self)._create_invoice_from_picking(cr, uid, picking, vals, context=context) + if picking.move_lines and picking.move_lines[0].purchase_line_id: + purchase_id = picking.move_lines[0].purchase_line_id.order_id.id + purchase_line_ids = purchase_line_obj.search(cr, uid, [('order_id', '=', purchase_id), ('product_id.type', '=', 'service'), ('invoiced', '=', False)], context=context) + if purchase_line_ids: + inv_lines = [] + for po_line in purchase_line_obj.browse(cr, uid, purchase_line_ids, context=context): + acc_id = purchase_obj._choose_account_from_po_line(cr, uid, po_line, context=context) + inv_line_data = purchase_obj._prepare_inv_line(cr, uid, acc_id, po_line, context=context) + inv_line_id = invoice_line_obj.create(cr, uid, inv_line_data, context=context) + inv_lines.append(inv_line_id) + po_line.write({'invoice_lines': [(4, inv_line_id)]}) + invoice_line_obj.write(cr, uid, inv_lines, {'invoice_id': invoice_id}, context=context) + return invoice_id + class stock_warehouse(osv.osv): _inherit = 'stock.warehouse' diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 6400bf55c56..e50346eda2a 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -243,8 +243,9 @@ class sale_order(osv.osv): 'company_id': fields.many2one('res.company', 'Company'), 'section_id': fields.many2one('crm.case.section', 'Sales Team'), 'procurement_group_id': fields.many2one('procurement.group', 'Procurement group', copy=False), - + 'product_id': fields.related('order_line', 'product_id', type='many2one', relation='product.product', string='Product'), } + _defaults = { 'date_order': fields.datetime.now, 'order_policy': 'manual', diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index e4993b4cf1c..c4b6af73163 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -250,6 +250,7 @@ <field name="user_id"/> <field name="section_id" string="Sales Team" groups="base.group_multi_salesteams"/> <field name="project_id"/> + <field name="product_id"/> <filter string="My" domain="[('user_id','=',uid)]" name="my_sale_orders_filter"/> <separator/> <filter string="Quotations" name="draft" domain="[('state','in',('draft','sent'))]" help="Sales Order that haven't yet been confirmed"/> diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 815caeb3bb9..26038673474 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -789,12 +789,12 @@ class stock_picking(osv.osv): * Cancelled: has been cancelled, can't be confirmed anymore""" ), 'priority': fields.function(get_min_max_date, multi="min_max_date", fnct_inv=_set_priority, type='selection', selection=procurement.PROCUREMENT_PRIORITIES, string='Priority', - store={'stock.move': (_get_pickings, ['priority'], 20)}, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, select=1, help="Priority for this picking. Setting manually a value here would set it as priority for all the moves", + store={'stock.move': (_get_pickings, ['priority', 'picking_id'], 20)}, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, select=1, help="Priority for this picking. Setting manually a value here would set it as priority for all the moves", track_visibility='onchange', required=True), 'min_date': fields.function(get_min_max_date, multi="min_max_date", fnct_inv=_set_min_date, - store={'stock.move': (_get_pickings, ['date_expected'], 20)}, type='datetime', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, string='Scheduled Date', select=1, help="Scheduled time for the first part of the shipment to be processed. Setting manually a value here would set it as expected date for all the stock moves.", track_visibility='onchange'), + store={'stock.move': (_get_pickings, ['date_expected', 'picking_id'], 20)}, type='datetime', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, string='Scheduled Date', select=1, help="Scheduled time for the first part of the shipment to be processed. Setting manually a value here would set it as expected date for all the stock moves.", track_visibility='onchange'), 'max_date': fields.function(get_min_max_date, multi="min_max_date", - store={'stock.move': (_get_pickings, ['date_expected'], 20)}, type='datetime', string='Max. Expected Date', select=2, help="Scheduled time for the last part of the shipment to be processed"), + store={'stock.move': (_get_pickings, ['date_expected', 'picking_id'], 20)}, type='datetime', string='Max. Expected Date', select=2, help="Scheduled time for the last part of the shipment to be processed"), 'date': fields.datetime('Creation Date', help="Creation Date, usually the time of the order", select=True, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, track_visibility='onchange'), 'date_done': fields.datetime('Date of Transfer', help="Date of Completion", states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, copy=False), 'move_lines': fields.one2many('stock.move', 'picking_id', 'Internal Moves', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}, copy=True), @@ -938,7 +938,8 @@ class stock_picking(osv.osv): 'pack_operation_ids': [], 'backorder_id': picking.id, }) - self.message_post(cr, uid, picking.id, body=_("Back order <em>%s</em> <b>created</b>.") % (picking.name), context=context) + backorder = self.browse(cr, uid, backorder_id, context=context) + self.message_post(cr, uid, picking.id, body=_("Back order <em>%s</em> <b>created</b>.") % (backorder.name), context=context) move_obj = self.pool.get("stock.move") move_obj.write(cr, uid, backorder_move_ids, {'picking_id': backorder_id}, context=context) diff --git a/addons/stock/stock_demo.xml b/addons/stock/stock_demo.xml index 5bada91afd2..316acce0b7e 100644 --- a/addons/stock/stock_demo.xml +++ b/addons/stock/stock_demo.xml @@ -77,7 +77,7 @@ <field name="product_id" ref="product.product_product_6"/> <field name="product_uom_id" ref="product.product_uom_unit"/> <field name="inventory_id" ref="stock_inventory_0"/> - <field name="product_qty">10.0</field> + <field name="product_qty">500.0</field> <field name="location_id" ref="stock_location_components"/> </record> <record id="stock_inventory_line_4" model="stock.inventory.line"> diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 32946ccba02..51e0e595e65 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -687,18 +687,18 @@ <field name="note" placeholder="Add an internal note..." class="oe_inline"/> </page> <page string="Operations" attrs="{'invisible': ['|', ('state','!=','done'), ('pack_operation_ids','=',[])]}"> - <field name="pack_operation_ids"> + <field name="pack_operation_ids" context="{'default_picking_id': active_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id}"> <tree editable="top"> <field name="package_id" groups="stock.group_tracking_lot"/> - <field name="product_id"/> + <field name="product_id" on_change="product_id_change(product_id, product_uom_id, product_qty)"/> <field name="product_uom_id" groups="product.group_uom"/> <field name="lot_id" domain="[('product_id','=?', product_id)]" context="{'product_id': product_id}" groups="stock.group_production_lot"/> <field name="picking_id" invisible="1"/> <field name="owner_id" groups="stock.group_tracking_owner"/> <field name="product_qty" attrs="{'required': [('product_id', '!=', False)]}"/> - <field name="location_id"/> - <field name="location_dest_id"/> - <field name="result_package_id" groups="stock.group_tracking_lot"/> + <field name="location_id" domain="[('id', 'child_of', parent.location_id)]"/> + <field name="location_dest_id" domain="[('id', 'child_of', parent.location_dest_id)]"/> + <field name="result_package_id" groups="stock.group_tracking_lot" context="{'location_id': location_dest_id}"/> </tree> </field> <p class="oe_grey" groups="stock.group_tracking_lot"> diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py index 1e7b19fef71..961eb2e0aef 100644 --- a/addons/stock/wizard/stock_change_product_qty.py +++ b/addons/stock/wizard/stock_change_product_qty.py @@ -98,7 +98,8 @@ class stock_change_product_qty(osv.osv_memory): 'product_id': data.product_id.id, 'location_id': data.location_id.id, 'lot_id': data.lot_id.id}, context=context) - th_qty = data.product_id.qty_available + product = data.product_id.with_context(location=data.location_id.id) + th_qty = product.qty_available line_data = { 'inventory_id': inventory_id, 'product_qty': data.new_quantity, diff --git a/addons/stock_account/stock.py b/addons/stock_account/stock.py index 555ced13758..aecf8d32694 100644 --- a/addons/stock_account/stock.py +++ b/addons/stock_account/stock.py @@ -191,7 +191,7 @@ class stock_picking(osv.osv): pick = self.browse(cr, uid, picking_id, context=context) moves = [x.id for x in pick.move_lines] move_obj= self.pool.get("stock.move") - move_obj.write(cr, uid, moves, {'invoice_state': pick.invoice_state}) + move_obj.write(cr, uid, moves, {'invoice_state': pick.invoice_state}, context=context) _columns = { 'invoice_state': fields.function(__get_invoice_state, type='selection', selection=[ |
