[MERGE]: Merge with lp:~openerp-commiter/openobject-addons/dev-addons2-rha1
bzr revid: rpa@tinyerp.com-20110107130246-ve4c015v6w3nr20d
This commit is contained in:
parent
b61007cb7d
commit
48211d0c83
|
@ -455,6 +455,7 @@ class purchase_order(osv.osv):
|
|||
'state': 'draft',
|
||||
'purchase_line_id': order_line.id,
|
||||
'company_id': order.company_id.id,
|
||||
'price_unit': order_line.price_unit
|
||||
})
|
||||
if order_line.move_dest_id:
|
||||
self.pool.get('stock.move').write(cr, uid, [order_line.move_dest_id.id], {'location_id':order.location_id.id})
|
||||
|
@ -816,4 +817,20 @@ class procurement_order(osv.osv):
|
|||
|
||||
procurement_order()
|
||||
|
||||
class stock_invoice_onshipping(osv.osv_memory):
|
||||
_inherit = "stock.invoice.onshipping"
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
purchase_obj = self.pool.get('purchase.order')
|
||||
picking_obj = self.pool.get('stock.picking')
|
||||
res = super(stock_invoice_onshipping,self).create_invoice(cr, uid, ids, context=context)
|
||||
purchase_id = picking_obj.browse(cr, uid, res.keys()[0]).purchase_id.id
|
||||
purchase_obj.write(cr, uid, [purchase_id], {
|
||||
'invoice_ids': [(4, res.values()[0])]}, context=context)
|
||||
return res
|
||||
|
||||
stock_invoice_onshipping()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<menuitem
|
||||
id="menu_purchase_config_pricelist" name="Pricelists"
|
||||
parent="menu_purchase_config_purchase" sequence="50"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="product.product_pricelist_action" id="menu_product_pricelist_action_purhase"
|
||||
parent="menu_purchase_config_pricelist" sequence="20"/>
|
||||
|
@ -32,7 +32,7 @@
|
|||
<menuitem
|
||||
id="menu_product_in_config_purchase" name="Product"
|
||||
parent="menu_purchase_config_purchase" sequence="30"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="product.product_category_action_form" id="menu_product_category_config_purchase"
|
||||
parent="purchase.menu_product_in_config_purchase" sequence="10"/>
|
||||
|
@ -40,7 +40,7 @@
|
|||
<menuitem
|
||||
id="menu_purchase_unit_measure_purchase" name="Units of Measure"
|
||||
parent="purchase.menu_product_in_config_purchase" sequence="20"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
action="product.product_uom_categ_form_action" id="menu_purchase_uom_categ_form_action"
|
||||
parent="menu_purchase_unit_measure_purchase" sequence="30"/>
|
||||
|
@ -113,10 +113,10 @@
|
|||
<!--product menu-->
|
||||
<menuitem id="menu_procurement_management_product" name="Products"
|
||||
parent="base.menu_purchase_root" sequence="8"/>
|
||||
|
||||
|
||||
<menuitem name="Products by Category" id="menu_product_by_category_purchase_form" action="product.product_category_action"
|
||||
parent="menu_procurement_management_product" sequence="10"/>
|
||||
|
||||
|
||||
<menuitem name="Products" id="menu_procurement_partner_contact_form" action="product.product_normal_action_puchased"
|
||||
parent="menu_procurement_management_product"/>
|
||||
|
||||
|
@ -292,7 +292,7 @@
|
|||
<field name="search_view_id" ref="view_purchase_order_filter"/>
|
||||
<field name="help">You can create a request for quotation when you want to buy products to a supplier but the purchase is not confirmed yet. Use also this menu to review requests for quotation created automatically based on your logistic rules (minimum stock, MTO, etc). You can convert the request for quotation into a purchase order once the order is confirmed. If you use the extended interface (from user's preferences), you can select the way to control your supplier invoices: based on the order, based on the receptions or manual encoding.</field>
|
||||
</record>
|
||||
<menuitem action="purchase_rfq" id="menu_purchase_rfq"
|
||||
<menuitem action="purchase_rfq" id="menu_purchase_rfq"
|
||||
parent="menu_procurement_management"
|
||||
sequence="6"/>
|
||||
|
||||
|
@ -458,7 +458,7 @@
|
|||
<field name="name">Purchase Lines Not Invoiced</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">purchase.order.line</field>
|
||||
<field name="domain">[('state','in',('confirmed','done')), ('invoiced', '=', False)]</field>
|
||||
<field name="domain">[('order_id.invoice_method','<>','picking'), ('state','in',('confirmed','done')), ('invoiced', '=', False)]</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="purchase_order_line_search"/>
|
||||
|
|
|
@ -1170,6 +1170,7 @@ class stock_picking(osv.osv):
|
|||
complete, too_many, too_few = [], [], []
|
||||
move_product_qty = {}
|
||||
prodlot_ids = {}
|
||||
product_avail = {}
|
||||
for move in pick.move_lines:
|
||||
if move.state in ('done', 'cancel'):
|
||||
continue
|
||||
|
@ -1195,6 +1196,12 @@ class stock_picking(osv.osv):
|
|||
move_currency_id = move.company_id.currency_id.id
|
||||
context['currency_id'] = move_currency_id
|
||||
qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id)
|
||||
|
||||
if product.id in product_avail:
|
||||
product_avail[product.id] += qty
|
||||
else:
|
||||
product_avail[product.id] = product.qty_available
|
||||
|
||||
if qty > 0:
|
||||
new_price = currency_obj.compute(cr, uid, product_currency,
|
||||
move_currency_id, product_price)
|
||||
|
@ -1205,9 +1212,8 @@ class stock_picking(osv.osv):
|
|||
else:
|
||||
# Get the standard price
|
||||
amount_unit = product.price_get('standard_price', context)[product.id]
|
||||
new_std_price = ((amount_unit * product.qty_available)\
|
||||
+ (new_price * qty))/(product.qty_available + qty)
|
||||
|
||||
new_std_price = ((amount_unit * product_avail[product.id])\
|
||||
+ (new_price * qty))/(product_avail[product.id] + qty)
|
||||
# Write the field according to price type field
|
||||
product_obj.write(cr, uid, [product.id], {'standard_price': new_std_price})
|
||||
|
||||
|
|
|
@ -85,34 +85,18 @@ class stock_invoice_onshipping(osv.osv_memory):
|
|||
raise osv.except_osv(_('Warning !'), _('None of these picking lists require invoicing.'))
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
def open_invoice(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
picking_pool = self.pool.get('stock.picking')
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
onshipdata_obj = self.read(cr, uid, ids[0], ['journal_id', 'group', 'invoice_date'])
|
||||
if context.get('new_picking', False):
|
||||
onshipdata_obj['id'] = onshipdata_obj.new_picking
|
||||
onshipdata_obj[ids] = onshipdata_obj.new_picking
|
||||
|
||||
context['date_inv'] = onshipdata_obj['invoice_date']
|
||||
invoice_ids = []
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_picking = picking_pool.browse(cr, uid, context.get('active_id',False), context=context)
|
||||
inv_type = picking_pool._get_invoice_type(active_picking)
|
||||
|
||||
res = picking_pool.action_invoice_create(cr, uid, active_ids,
|
||||
journal_id = onshipdata_obj['journal_id'],
|
||||
group = onshipdata_obj['group'],
|
||||
type = None,
|
||||
context=context)
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
res = self.create_invoice(cr, uid, ids, context=context)
|
||||
invoice_ids += res.values()
|
||||
if not invoice_ids:
|
||||
raise osv.except_osv(_('Error'), _('No Invoices were created'))
|
||||
inv_type = context.get('inv_type', False)
|
||||
action_model = False
|
||||
action = {}
|
||||
if not invoice_ids:
|
||||
raise osv.except_osv(_('Error'), _('No Invoices were created'))
|
||||
if inv_type == "out_invoice":
|
||||
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree1")
|
||||
elif inv_type == "in_invoice":
|
||||
|
@ -127,6 +111,26 @@ class stock_invoice_onshipping(osv.osv_memory):
|
|||
action['domain'] = "[('id','in', ["+','.join(map(str,invoice_ids))+"])]"
|
||||
return action
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
picking_pool = self.pool.get('stock.picking')
|
||||
onshipdata_obj = self.read(cr, uid, ids, ['journal_id', 'group', 'invoice_date'])
|
||||
if context.get('new_picking', False):
|
||||
onshipdata_obj['id'] = onshipdata_obj.new_picking
|
||||
onshipdata_obj[ids] = onshipdata_obj.new_picking
|
||||
context['date_inv'] = onshipdata_obj[0]['invoice_date']
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_picking = picking_pool.browse(cr, uid, context.get('active_id',False), context=context)
|
||||
inv_type = picking_pool._get_invoice_type(active_picking)
|
||||
context['inv_type'] = inv_type
|
||||
res = picking_pool.action_invoice_create(cr, uid, active_ids,
|
||||
journal_id = onshipdata_obj[0]['journal_id'],
|
||||
group = onshipdata_obj[0]['group'],
|
||||
type = None,
|
||||
context=context)
|
||||
return res
|
||||
|
||||
stock_invoice_onshipping()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<field name="invoice_date" />
|
||||
<separator string="" colspan="4" />
|
||||
<button special="cancel" string="_Cancel" icon='gtk-cancel'/>
|
||||
<button name="create_invoice" string="Create" type="object" icon="terp-gtk-go-back-rtl"/>
|
||||
<button name="open_invoice" string="Create" type="object" icon="terp-gtk-go-back-rtl"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -32,24 +32,24 @@ class stock_partial_picking(osv.osv_memory):
|
|||
'product_moves_out' : fields.one2many('stock.move.memory.out', 'wizard_id', 'Moves'),
|
||||
'product_moves_in' : fields.one2many('stock.move.memory.in', 'wizard_id', 'Moves'),
|
||||
}
|
||||
|
||||
|
||||
def __is_in(self,cr, uid, pick_ids):
|
||||
"""
|
||||
@return: True if one of the moves has as picking type 'in'
|
||||
"""
|
||||
if not pick_ids:
|
||||
return False
|
||||
|
||||
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
pick_ids = pick_obj.search(cr, uid, [('id','in',pick_ids)])
|
||||
|
||||
|
||||
|
||||
|
||||
for pick in pick_obj.browse(cr, uid, pick_ids):
|
||||
for move in pick.move_lines:
|
||||
if pick.type == 'in' and move.product_id.cost_method == 'average':
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def __get_picking_type(self, cr, uid, pick_ids):
|
||||
if self.__is_in(cr, uid, pick_ids):
|
||||
return "product_moves_in"
|
||||
|
@ -62,11 +62,11 @@ class stock_partial_picking(osv.osv_memory):
|
|||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
|
||||
result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
|
||||
|
||||
|
||||
|
||||
|
||||
picking_ids = context.get('active_ids', False)
|
||||
picking_type = self.__get_picking_type(cr, uid, picking_ids)
|
||||
|
||||
|
||||
_moves_arch_lst = """<form string="%s">
|
||||
<field name="date" invisible="1"/>
|
||||
<separator colspan="4" string="%s"/>
|
||||
|
@ -77,7 +77,7 @@ class stock_partial_picking(osv.osv_memory):
|
|||
'product_moves_in' : {'relation': 'stock.move.memory.in', 'type' : 'one2many', 'string' : 'Product Moves'},
|
||||
'product_moves_out' : {'relation': 'stock.move.memory.out', 'type' : 'one2many', 'string' : 'Product Moves'}
|
||||
})
|
||||
|
||||
|
||||
_moves_arch_lst += """
|
||||
<separator string="" colspan="4" />
|
||||
<label string="" colspan="2"/>
|
||||
|
@ -100,10 +100,10 @@ class stock_partial_picking(osv.osv_memory):
|
|||
'prodlot_id' : picking.prodlot_id.id,
|
||||
'move_id' : picking.id,
|
||||
}
|
||||
|
||||
|
||||
if is_in:
|
||||
move_memory.update({
|
||||
'cost' : picking.product_id.standard_price,
|
||||
'cost' : picking.price_unit,
|
||||
'currency' : picking.product_id.company_id.currency_id.id,
|
||||
})
|
||||
return move_memory
|
||||
|
@ -112,23 +112,23 @@ class stock_partial_picking(osv.osv_memory):
|
|||
pick_obj = self.pool.get('stock.picking')
|
||||
if not context:
|
||||
context = {}
|
||||
|
||||
|
||||
res = []
|
||||
for pick in pick_obj.browse(cr, uid, context.get('active_ids', []), context):
|
||||
need_product_cost = (pick.type == 'in')
|
||||
for m in pick.move_lines:
|
||||
if m.state in ('done', 'cancel'):
|
||||
continue
|
||||
continue
|
||||
res.append(self.__create_partial_picking_memory(m, need_product_cost))
|
||||
|
||||
|
||||
return res
|
||||
|
||||
|
||||
_defaults = {
|
||||
'product_moves_in' : __get_active_stock_pickings,
|
||||
'product_moves_out' : __get_active_stock_pickings,
|
||||
'date' : lambda *a : time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
}
|
||||
|
||||
|
||||
|
||||
def do_partial(self, cr, uid, ids, context=None):
|
||||
""" Makes partial moves and pickings done.
|
||||
|
@ -152,22 +152,22 @@ class stock_partial_picking(osv.osv_memory):
|
|||
p_moves = {}
|
||||
for product_move in moves_list:
|
||||
p_moves[product_move.move_id.id] = product_move
|
||||
|
||||
|
||||
|
||||
|
||||
for move in pick.move_lines:
|
||||
if move.state in ('done', 'cancel'):
|
||||
continue
|
||||
if not p_moves.get(move.id):
|
||||
continue
|
||||
|
||||
|
||||
partial_datas['move%s' % (move.id)] = {
|
||||
'product_id' : p_moves[move.id].id,
|
||||
'product_qty' : p_moves[move.id].quantity,
|
||||
'product_uom' :p_moves[move.id].product_uom.id,
|
||||
'prodlot_id' : p_moves[move.id].prodlot_id.id,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (move.picking_id.type == 'in') and (move.product_id.cost_method == 'average'):
|
||||
partial_datas['move%s' % (move.id)].update({
|
||||
'product_price' : p_moves[move.id].cost,
|
||||
|
@ -176,8 +176,8 @@ class stock_partial_picking(osv.osv_memory):
|
|||
pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
stock_partial_picking()
|
||||
|
||||
|
|
Loading…
Reference in New Issue