Skip to content

Commit

Permalink
Merge pull request odoo#2502 from odoo-dev/8.0-wmsstaging9-jco
Browse files Browse the repository at this point in the history
8.0 wmsstaging9 jco
  • Loading branch information
jco-odoo committed Sep 17, 2014
2 parents 8aca409 + 5aeccbd commit ccc3e7f
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 48 deletions.
8 changes: 2 additions & 6 deletions addons/delivery/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ def _cal_move_weight(self, cr, uid, ids, name, args, context=None):
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:
Expand All @@ -165,11 +161,11 @@ def _cal_move_weight(self, cr, uid, ids, name, args, context=None):
_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",),
}
Expand Down
4 changes: 3 additions & 1 deletion addons/mrp/mrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ def _create_previous_move(self, cr, uid, move_id, product, source_location_id, d

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
Expand All @@ -1107,7 +1108,7 @@ def _make_consume_line_from_data(self, cr, uid, production, product, uom_id, qty
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,
Expand All @@ -1125,6 +1126,7 @@ def _make_consume_line_from_data(self, cr, uid, production, product, uom_id, qty
#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:
Expand Down
1 change: 0 additions & 1 deletion addons/mrp/mrp_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion addons/mrp_repair/mrp_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def product_id_change(self, cr, uid, ids, pricelist, product, uom=False,
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 = {
Expand Down
3 changes: 2 additions & 1 deletion addons/product/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,9 +1007,10 @@ def _name_get(d):
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))
Expand Down
25 changes: 13 additions & 12 deletions addons/product_extended/product_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def compute_price(self, cr, uid, ids, recursive=False, test=False, real_time_acc
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)
Expand All @@ -63,10 +63,10 @@ def _calc_price(self, cr, uid, bom, test = False, real_time_accounting=False, co
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:
Expand All @@ -79,15 +79,16 @@ def _calc_price(self, cr, uid, bom, test = False, real_time_accounting=False, co
#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
Expand Down
19 changes: 8 additions & 11 deletions addons/purchase/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,23 +679,19 @@ def wkf_action_cancel(self, cr, uid, ids, context=None):
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(
_('Unable to cancel this purchase order.'),
_('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

Expand Down Expand Up @@ -1156,6 +1152,7 @@ def action_confirm(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'confirmed'}, context=context)
return True


class procurement_rule(osv.osv):
_inherit = 'procurement.rule'

Expand Down Expand Up @@ -1287,7 +1284,7 @@ def _get_po_line_values_from_proc(self, cr, uid, procurement, partner, company,
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

Expand Down
3 changes: 1 addition & 2 deletions addons/purchase/purchase_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
19 changes: 19 additions & 0 deletions addons/purchase/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ def _get_picking_to_recompute(self, cr, uid, ids, context=None):
}),
}

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'
Expand Down
3 changes: 2 additions & 1 deletion addons/sale/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ def _resolve_section_id_from_context(self, cr, uid, context=None):
'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',
Expand Down
1 change: 1 addition & 0 deletions addons/sale/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
9 changes: 5 additions & 4 deletions addons/stock/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,12 +789,12 @@ def action_assign_owner(self, cr, uid, ids, context=None):
* 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),
Expand Down Expand Up @@ -938,7 +938,8 @@ def _create_backorder(self, cr, uid, picking, backorder_moves=[], context=None):
'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)

Expand Down
2 changes: 1 addition & 1 deletion addons/stock/stock_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Loading

0 comments on commit ccc3e7f

Please sign in to comment.