diff --git a/addons/mrp/security/ir.model.access.csv b/addons/mrp/security/ir.model.access.csv
index 586f82f1b53..dcbf6c866b4 100644
--- a/addons/mrp/security/ir.model.access.csv
+++ b/addons/mrp/security/ir.model.access.csv
@@ -67,3 +67,4 @@
"access_stock_picking_mrp_manager","stock.picking mrp_manager","stock.model_stock_picking","mrp.group_mrp_manager",1,0,0,0
"access_report_mrp_inout_user","report.mrp.inout user","model_report_mrp_inout","mrp.group_mrp_user",1,0,0,0
"access_report_workcenter_load_user","report.workcenter.load.user","model_report_workcenter_load","mrp.group_mrp_user",1,0,0,0
+"access_mrp_bom","mrp.bom","model_mrp_bom","base.group_sale_salesman",1,0,0,0
diff --git a/addons/sale/security/ir.model.access.csv b/addons/sale/security/ir.model.access.csv
index 11718051d04..39b1996ee88 100644
--- a/addons/sale/security/ir.model.access.csv
+++ b/addons/sale/security/ir.model.access.csv
@@ -1,5 +1,5 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-"access_sale_shop","sale.shop","model_sale_shop","base.group_user",1,0,0,0
+"access_sale_shop","sale.shop","model_sale_shop","base.group_user",1,1,0,0
"access_sale_order","sale.order","model_sale_order","base.group_sale_salesman",1,1,1,0
"access_sale_order_line","sale.order.line","model_sale_order_line","base.group_sale_salesman",1,1,1,1
"access_account_invoice_tax_salesman","account_invoice_tax salesman","account.model_account_invoice_tax","base.group_sale_salesman",1,1,1,0
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index e6737ae31bb..444cd3790b2 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -930,6 +930,25 @@ class stock_picking(osv.osv):
'''Call after the creation of the invoice'''
return
+ def _get_invoice_type(self, pick):
+ src_usage = dest_usage = None
+ inv_type = None
+ if pick.invoice_state == '2binvoiced':
+ if pick.move_lines:
+ src_usage = pick.move_lines[0].location_id.usage
+ dest_usage = pick.move_lines[0].location_dest_id.usage
+ if pick.type == 'out' and dest_usage == 'supplier':
+ inv_type = 'in_refund'
+ elif pick.type == 'out' and dest_usage == 'customer':
+ inv_type = 'out_invoice'
+ elif pick.type == 'in' and src_usage == 'supplier':
+ inv_type = 'in_invoice'
+ elif pick.type == 'in' and src_usage == 'customer':
+ inv_type = 'out_refund'
+ else:
+ inv_type = 'out_invoice'
+ return inv_type
+
def action_invoice_create(self, cr, uid, ids, journal_id=False,
group=False, type='out_invoice', context=None):
""" Creates invoice based on the invoice state selected for picking.
@@ -945,7 +964,7 @@ class stock_picking(osv.osv):
invoice_line_obj = self.pool.get('account.invoice.line')
invoices_group = {}
res = {}
-
+ inv_type = type
for picking in self.browse(cr, uid, ids, context=context):
if picking.invoice_state != '2binvoiced':
continue
@@ -954,8 +973,11 @@ class stock_picking(osv.osv):
if not partner:
raise osv.except_osv(_('Error, no partner !'),
_('Please put a partner on the picking list if you want to generate invoice.'))
+
+ if not inv_type:
+ inv_type = self._get_invoice_type(picking)
- if type in ('out_invoice', 'out_refund'):
+ if inv_type in ('out_invoice', 'out_refund'):
account_id = partner.property_account_receivable.id
payment_term_id = self._get_payment_term(cr, uid, picking)
else:
@@ -980,7 +1002,7 @@ class stock_picking(osv.osv):
invoice_vals = {
'name': picking.name,
'origin': (picking.name or '') + (picking.origin and (':' + picking.origin) or ''),
- 'type': type,
+ 'type': inv_type,
'account_id': account_id,
'partner_id': partner.id,
'address_invoice_id': address_invoice_id,
@@ -1012,7 +1034,7 @@ class stock_picking(osv.osv):
else:
name = move_line.name
- if type in ('out_invoice', 'out_refund'):
+ if inv_type in ('out_invoice', 'out_refund'):
account_id = move_line.product_id.product_tmpl_id.\
property_account_income.id
if not account_id:
@@ -1026,14 +1048,14 @@ class stock_picking(osv.osv):
property_account_expense_categ.id
price_unit = self._get_price_unit_invoice(cr, uid,
- move_line, type)
+ move_line, inv_type)
discount = self._get_discount_invoice(cr, uid, move_line)
- tax_ids = self._get_taxes_invoice(cr, uid, move_line, type)
+ tax_ids = self._get_taxes_invoice(cr, uid, move_line, inv_type)
account_analytic_id = self._get_account_analytic_invoice(cr, uid, picking, move_line)
#set UoS if it's a sale and the picking doesn't have one
uos_id = move_line.product_uos and move_line.product_uos.id or False
- if not uos_id and type in ('out_invoice', 'out_refund'):
+ if not uos_id and inv_type in ('out_invoice', 'out_refund'):
uos_id = move_line.product_uom.id
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, partner.property_account_position, account_id)
@@ -1053,7 +1075,7 @@ class stock_picking(osv.osv):
self._invoice_line_hook(cr, uid, move_line, invoice_line_id)
invoice_obj.button_compute(cr, uid, [invoice_id], context=context,
- set_total=(type in ('in_invoice', 'in_refund')))
+ set_total=(inv_type in ('in_invoice', 'in_refund')))
self.write(cr, uid, [picking.id], {
'invoice_state': 'invoiced',
}, context=context)
@@ -1480,7 +1502,7 @@ class stock_move(osv.osv):
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Optional: next stock move when chaining them", select=True),
'move_history_ids': fields.many2many('stock.move', 'stock_move_history_ids', 'parent_id', 'child_id', 'Move History (child moves)'),
'move_history_ids2': fields.many2many('stock.move', 'stock_move_history_ids', 'child_id', 'parent_id', 'Move History (parent moves)'),
- 'picking_id': fields.many2one('stock.picking', 'Picking List', select=True,states={'done': [('readonly', True)]}),
+ 'picking_id': fields.many2one('stock.picking', 'Reference', select=True,states={'done': [('readonly', True)]}),
'note': fields.text('Notes'),
'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Available\'.\n When the picking is done the state is \'Done\'.\
@@ -2231,7 +2253,7 @@ class stock_move(osv.osv):
quantity_rest = quantity
uos_qty_rest = uos_qty
if move.product_id.track_production and location_id:
- res += self.split_lines(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
+ res += self.action_split(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
else:
res += [move.id]
update_val = {
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index dfe01760d1a..61bc8b887de 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -304,7 +304,7 @@
-
+
@@ -317,7 +317,7 @@
-
+
@@ -449,7 +449,7 @@
-
+
@@ -726,7 +726,7 @@
-
+
@@ -919,7 +919,7 @@
-
+
@@ -1139,7 +1139,7 @@
-
+
@@ -1461,9 +1461,9 @@
Reception Picking (By Stock Move)
====================================
-
-
-
+
+
+
stock.move.tree2
stock.move
@@ -1523,7 +1523,7 @@
-
+
stock.move.form2
diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py
index 37d3634a988..7924ad0a31b 100644
--- a/addons/stock/wizard/stock_invoice_onshipping.py
+++ b/addons/stock/wizard/stock_invoice_onshipping.py
@@ -24,14 +24,52 @@ from osv import fields, osv
from tools.translate import _
class stock_invoice_onshipping(osv.osv_memory):
+
+ def _get_journal_id(self, cr, uid, context=None):
+ if context is None:
+ context = {}
+
+ model = context.get('active_model')
+ if not model or model != 'stock.picking':
+ return []
+
+ model_pool = self.pool.get(model)
+ acct_obj = self.pool.get('account.journal')
+ res_ids = context and context.get('active_ids', [])
+ vals=[]
+ pick_types = list(set(map(lambda x: x.type, model_pool.browse(cr, uid, res_ids, context=context))))
+ for type in pick_types:
+ if type == 'out':
+ value = acct_obj.search(cr, uid, [('type', 'in',('sale','sale_refund') )])
+ for jr_type in acct_obj.browse(cr, uid, value, context=context):
+ t1 = jr_type.id,jr_type.name
+ vals.append(t1)
+
+ elif type == 'in':
+ value = acct_obj.search(cr, uid, [('type', 'in',('purchase','purchase_refund') )])
+ for jr_type in acct_obj.browse(cr, uid, value, context=context):
+ t1 = jr_type.id,jr_type.name
+ vals.append(t1)
+ else:
+ value = acct_obj.search(cr, uid, [('type', 'in',('cash','bank','general','situation') )])
+ for jr_type in acct_obj.browse(cr, uid, value, context=context):
+ t1 = jr_type.id,jr_type.name
+ vals.append(t1)
+ return vals
+
+
_name = "stock.invoice.onshipping"
_description = "Stock Invoice Onshipping"
+
+
_columns = {
- 'journal_id': fields.many2one('account.journal', 'Destination Journal', required=True),
+# 'journal_id': fields.many2one('account.journal', 'Destination Journal', required=True,selection=_get_journal_id),
+ 'journal_id': fields.selection(_get_journal_id, 'Destination Journal',required=True),
'group': fields.boolean("Group by partner"),
'invoice_date': fields.date('Invoiced date'),
}
+
def view_init(self, cr, uid, fields_list, context=None):
if context is None:
context = {}
@@ -48,30 +86,13 @@ class stock_invoice_onshipping(osv.osv_memory):
raise osv.except_osv(_('Warning !'), _('None of these picking lists require invoicing.'))
return res
- def _get_type(self, pick):
- src_usage = dest_usage = None
- pick_type = None
- if pick.invoice_state=='2binvoiced':
- if pick.move_lines:
- src_usage = pick.move_lines[0].location_id.usage
- dest_usage = pick.move_lines[0].location_dest_id.usage
- if pick.type == 'out' and dest_usage == 'supplier':
- pick_type = 'in_refund'
- elif pick.type == 'out' and dest_usage == 'customer':
- pick_type = 'out_invoice'
- elif pick.type == 'in' and src_usage == 'supplier':
- pick_type = 'in_invoice'
- elif pick.type == 'in' and src_usage == 'customer':
- pick_type = 'out_refund'
- else:
- pick_type = 'out_invoice'
- return pick_type
+
def create_invoice(self, cr, uid, ids, context=None):
if context is None:
context = {}
- result = []
- picking_obj = self.pool.get('stock.picking')
+ 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
@@ -79,33 +100,33 @@ class stock_invoice_onshipping(osv.osv_memory):
context['date_inv'] = onshipdata_obj['invoice_date']
invoice_ids = []
- for picking in picking_obj.browse(cr, uid, context.get('active_ids', []), context=context):
- if picking.invoice_state == '2binvoiced':
- res = picking_obj.action_invoice_create(cr, uid, [picking.id],
- journal_id = onshipdata_obj['journal_id'],
- group=onshipdata_obj['group'],
- type=self._get_type(picking),
- context=context)
- invoice_ids.extend(res.values())
- context['journal_type'] = {
- 'out_invoice': 'sale',
- 'out_refund': 'sale_refund',
- 'in_invoice': 'purchase',
- 'in_refund': 'purchase_refund'
- }.get(self._get_type(picking), 'sale')
+ 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)
+ invoice_ids += res.values()
if not invoice_ids:
- raise osv.except_osv(_('Error'), _('No invoice were created'))
-
- return {
- 'domain': "[('id','in', ["+','.join(map(str,invoice_ids))+"])]",
- 'name' : _('Invoices'),
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'account.invoice',
- 'context': context,
- 'type': 'ir.actions.act_window',
- }
+ raise osv.except_osv(_('Error'), _('No Invoices were created'))
+ action_model = False
+ action = {}
+ 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":
+ action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree2")
+ elif inv_type == "out_refund":
+ action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree3")
+ elif inv_type == "in_refund":
+ action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree4")
+ if action_model:
+ action_pool = self.pool.get(action_model)
+ action = action_pool.read(cr, uid, action_id, context=context)
+ action['domain'] = "[('id','in', ["+','.join(map(str,invoice_ids))+"])]"
+ return action
stock_invoice_onshipping()
diff --git a/addons/stock_location/security/ir.model.access.csv b/addons/stock_location/security/ir.model.access.csv
index d3815736408..fc4eeff788b 100644
--- a/addons/stock_location/security/ir.model.access.csv
+++ b/addons/stock_location/security/ir.model.access.csv
@@ -6,3 +6,5 @@
"access_stock_location_path_manager","stock location path manager","model_stock_location_path","stock.group_stock_manager",1,1,1,1
"access_stock_location_path_partner_manager","stock.location.path partner manager","model_stock_location_path","product.group_product_manager",1,1,1,1
"access_stock_location_path_stock_user","stock.location.path stock user","model_stock_location_path","stock.group_stock_user",1,1,1,1
+"access_stock_location_path","stock.location.path","model_stock_location_path","base.group_sale_salesman",1,0,0,0
+"access_product_pulled_flow","product.pulled.flow","model_product_pulled_flow","base.group_sale_salesman",1,0,0,0