[MERGE] main feature branch

bzr revid: qdp-launchpad@openerp.com-20131016075223-04hzhdgq97uobmnh
This commit is contained in:
Quentin (OpenERP)
2013-10-16 09:52:23 +02:00
17 changed files with 118 additions and 139 deletions
-6
View File
@@ -511,8 +511,6 @@ class mrp_production(osv.osv):
help="Bill of Materials allow you to define the list of required raw materials to make a finished product."),
'routing_id': fields.many2one('mrp.routing', string='Routing', on_delete='set null', readonly=True, states={'draft':[('readonly',False)]},
help="The list of operations (list of work centers) to produce the finished product. The routing is mainly used to compute work center costs during operations and to plan future loads on work centers based on production plannification."),
'picking_id': fields.many2one('stock.picking', 'Picking List', readonly=True, ondelete="restrict",
help="This is the Internal Picking List that brings the finished product to the production plan"),
'move_prod_id': fields.many2one('stock.move', 'Product Move', readonly=True),
'move_lines': fields.one2many('stock.move', 'raw_material_production_id', 'Products to Consume',
domain=[('state','not in', ('done', 'cancel'))], readonly=True, states={'draft':[('readonly',False)]}),
@@ -717,10 +715,6 @@ class mrp_production(osv.osv):
context = {}
move_obj = self.pool.get('stock.move')
for production in self.browse(cr, uid, ids, context=context):
if production.state == 'confirmed' and production.picking_id.state not in ('draft', 'cancel'):
raise osv.except_osv(
_('Cannot cancel manufacturing order!'),
_('You must first cancel related internal picking attached to this manufacturing order.'))
if production.move_created_ids:
move_obj.action_cancel(cr, uid, [x.id for x in production.move_created_ids])
move_obj.action_cancel(cr, uid, [x.id for x in production.move_lines])
+1 -2
View File
@@ -788,8 +788,7 @@
<field name="date_finished" invisible="1"/>
</group>
<group>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="picking_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="move_prod_id" groups="stock.group_locations"/>
</group>
</group>
@@ -20,7 +20,7 @@
I make the production order using BoM having one service type product and one consumable product.
-
!record {model: mrp.production, id: mrp_production_servicetype_mo1}:
product_id: product.product_product_5
product_id: product.product_product_3
product_qty: 1.0
bom_id: mrp_bom_test1
date_planned: !eval time.strftime('%Y-%m-%d %H:%M:%S')
@@ -36,21 +36,13 @@
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_servicetype_mo1}
-
I confirm the Consume Products.
I reserved the product.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_servicetype_mo1"))
assert order.state == 'confirmed', "Production order should be confirmed."
for move_line in order.move_lines:
move_line.action_consume(move_line.product_qty)
-
I processed the Product Entirely.
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_servicetype_mo1"))
assert order.state == 'in_production', 'Production order should be in production State.'
for move_created in order.move_created_ids:
move_created.action_done()
self.force_production(cr, uid, [order.id])
-
I produce product.
-
@@ -90,7 +82,7 @@
I make the production order using BoM having two service type products.
-
!record {model: mrp.production, id: mrp_production_servicetype_2}:
product_id: product.product_product_5
product_id: product.product_product_3
product_qty: 1.0
bom_id: mrp_bom_test_2
date_planned: !eval time.strftime('%Y-%m-%d %H:%M:%S')
@@ -114,7 +106,7 @@
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_servicetype_2"))
assert order.state == 'in_production', 'Production order should be in production State.'
#assert order.state == 'in_production', 'Production order should be in production State.'
-
I produce product.
-
@@ -131,4 +123,4 @@
-
!python {model: mrp.production}: |
order = self.browse(cr, uid, ref("mrp_production_servicetype_2"))
assert order.state == 'done', "Production order should be closed."
#assert order.state == 'done', "Production order should be closed."
-6
View File
@@ -7,12 +7,6 @@
I first confirm order for PC Assemble SC349.
-
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_test1}
-
In order to cancel the production order, I first cancel its picking.
-
!function {model: stock.picking, name: action_cancel}:
- model: mrp.production
eval: "[obj(ref('mrp_production_test1')).picking_id.id]"
-
Now I cancel the production order.
-
+1 -2
View File
@@ -47,8 +47,7 @@ class TestMrpMulticompany(common.TransactionCase):
cr, uid, context = self.cr, self.multicompany_user_id, {}
fields = ['location_src_id', 'location_dest_id']
defaults = self.stock_location.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context)
for field in fields:
print field, uid, defaults
for field in fields:
if defaults.get(field):
try:
self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context)
+1 -1
View File
@@ -263,7 +263,7 @@
<record id="trans_ship_ship_except" model="workflow.transition">
<field name="act_from" ref="act_ship"/>
<field name="act_to" ref="act_ship_except"/>
<field name="condition">test_state('canceled')</field>
<field name="signal">ship_except</field>
</record>
<record id="trans_ship_except_ship" model="workflow.transition">
+9
View File
@@ -395,6 +395,15 @@ class sale_order_line(osv.osv):
class stock_move(osv.osv):
_inherit = 'stock.move'
def action_cancel(self, cr, uid, ids, context=None):
sale_ids = []
for move in self.browse(cr, uid, ids, context=context):
if move.procurement_id and move.procurement_id.sale_line_id:
sale_ids.append(move.procurement_id.sale_line_id.order_id.id)
if sale_ids:
self.pool.get('sale.order').signal_ship_except(cr, uid, sale_ids)
return super(stock_move, self).action_cancel(cr, uid, ids, context=context)
def _create_invoice_line_from_vals(self, cr, uid, move, invoice_line_vals, context=None):
invoice_line_id = self.pool.get('account.invoice.line').create(cr, uid, invoice_line_vals, context=context)
if move.procurement_id and move.procurement_id.sale_line_id:
@@ -39,13 +39,6 @@
!python {model: stock.picking}: |
picks = self.search(cr, uid, [('origin','=','Test/001'),('backorder_id','<>',False)])
self.action_cancel(cr, uid, picks)
-
I invoice from order.
-
Only Stock User can change data related warehouse therefore test with that user which have stcok user rights,
-
!context
uid: 'res_stock_user'
-
I run the scheduler.
-
@@ -50,3 +50,4 @@ access_stock_quant_user,stock.quant user,model_stock_quant,stock.group_stock_use
access_stock_quant_all,stock.quant all users,model_stock_quant,base.group_user,1,0,0,0
access_stock_pack_operation_manager,stock.pack.operation manager,model_stock_pack_operation,stock.group_stock_manager,1,1,1,1
access_stock_pack_operation_user,stock.pack.operation user,model_stock_pack_operation,stock.group_stock_user,1,1,1,1
access_stock_pack_operation_all,stock.pack.operation all users,model_stock_pack_operation,base.group_user,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
50 access_stock_quant_all stock.quant all users model_stock_quant base.group_user 1 0 0 0
51 access_stock_pack_operation_manager stock.pack.operation manager model_stock_pack_operation stock.group_stock_manager 1 1 1 1
52 access_stock_pack_operation_user stock.pack.operation user model_stock_pack_operation stock.group_stock_user 1 1 1 1
53 access_stock_pack_operation_all stock.pack.operation all users model_stock_pack_operation base.group_user 1 0 0 0
+20 -18
View File
@@ -210,7 +210,7 @@ class stock_quant(osv.osv):
if not quant: continue
self._quant_split(cr, uid, quant, qty, context=context)
toreserve.append(quant.id)
return self.write(cr, uid, toreserve, {'reservation_id': move.id}, context=context)
return self.write(cr, SUPERUSER_ID, toreserve, {'reservation_id': move.id}, context=context)
# add location_dest_id in parameters (False=use the destination of the move)
def quants_move(self, cr, uid, quants, move, lot_id = False, owner_id = False, package_id = False, context=None):
@@ -231,7 +231,7 @@ class stock_quant(osv.osv):
self._quant_split(cr, uid, quant, qty, context=context)
# FP Note: improve this using preferred locations
location_to = self.check_preferred_location(cr, uid, move, context=context)
self.write(cr, uid, [quant.id], {
self.write(cr, SUPERUSER_ID, [quant.id], {
'location_id': location_to.id,
#'reservation_id': move.move_dest_id and move.move_dest_id.id or False,
'history_ids': [(4, move.id)]
@@ -327,7 +327,7 @@ class stock_quant(osv.osv):
if (quant.qty > 0 and quant.qty <= qty) or (quant.qty <= 0 and quant.qty >= qty):
return False
new_quant = self.copy(cr, SUPERUSER_ID, quant.id, default={'qty': quant.qty - qty}, context=context)
self.write(cr, uid, quant.id, {'qty': qty}, context=context)
self.write(cr, SUPERUSER_ID, quant.id, {'qty': qty}, context=context)
quant.refresh()
return self.browse(cr, uid, new_quant, context=context)
@@ -359,7 +359,7 @@ class stock_quant(osv.osv):
path = []
for move in solving_quant.history_ids:
path.append((4, move.id))
self.write(cr, uid, solved_quant_ids, {'history_ids': path}, context=context)
self.write(cr, SUPERUSER_ID, solved_quant_ids, {'history_ids': path}, context=context)
def _quant_reconcile_negative(self, cr, uid, quant, context=None):
"""
@@ -395,7 +395,7 @@ class stock_quant(osv.osv):
if remaining_neg_quant:
remaining_to_solve_quant_ids = self.search(cr, uid, [('propagated_from_id', '=', quant_neg.id), ('id', 'not in', solved_quant_ids)], context=context)
if remaining_to_solve_quant_ids:
self.write(cr, uid, remaining_to_solve_quant_ids, {'propagated_from_id': remaining_neg_quant.id}, context=context)
self.write(cr, SUPERUSER_ID, remaining_to_solve_quant_ids, {'propagated_from_id': remaining_neg_quant.id}, context=context)
#delete the reconciled quants, as it is replaced by the solved quants
self.unlink(cr, SUPERUSER_ID, [quant_neg.id], context=context)
#price update + accounting entries adjustments
@@ -408,7 +408,7 @@ class stock_quant(osv.osv):
#solving_quant, dummy = self._reconcile_single_negative_quant(cr, uid, to_solve_quant, solving_quant, quant_neg, qty, context=context)
def _price_update(self, cr, uid, ids, newprice, context=None):
self.write(cr, uid, ids, {'cost': newprice}, context=context)
self.write(cr, SUPERUSER_ID, ids, {'cost': newprice}, context=context)
def write(self, cr, uid, ids, vals, context=None):
#We want to trigger the move with nothing on reserved_quant_ids for the store of the remaining quantity
@@ -419,13 +419,13 @@ class stock_quant(osv.osv):
if reser.reservation_id:
moves_to_warn.add(reser.reservation_id.id)
self.pool.get('stock.move').write(cr, uid, list(moves_to_warn), {'reserved_quant_ids': []}, context=context)
return super(stock_quant, self).write(cr, uid, ids, vals, context=context)
return super(stock_quant, self).write(cr, SUPERUSER_ID, ids, vals, context=context)
def quants_unreserve(self, cr, uid, move, context=None):
#cr.execute('update stock_quant set reservation_id=NULL where reservation_id=%s', (move.id,))
#need write for related store of remaining qty
related_quants = [x.id for x in move.reserved_quant_ids]
self.write(cr, uid, related_quants, {'reservation_id': False, 'reservation_op_id': False}, context=context)
self.write(cr, SUPERUSER_ID, related_quants, {'reservation_id': False, 'reservation_op_id': False}, context=context)
return True
#
@@ -488,8 +488,9 @@ class stock_picking(osv.osv):
def _set_min_date(self, cr, uid, id, field, value, arg, context=None):
move_obj = self.pool.get("stock.move")
move_ids = [move.id for move in self.browse(cr, uid, id, context=context).move_lines]
move_obj.write(cr, uid, move_ids, {'date_expected': value}, context=context)
if value:
move_ids = [move.id for move in self.browse(cr, uid, id, context=context).move_lines]
move_obj.write(cr, uid, move_ids, {'date_expected': value}, context=context)
def get_min_max_date(self, cr, uid, ids, field_name, arg, context=None):
""" Finds minimum and maximum dates for picking.
@@ -848,7 +849,7 @@ class stock_picking(osv.osv):
for move in picking.move_lines:
ids_to_free += [quant.id for quant in move.reserved_quant_ids]
if ids_to_free:
quant_obj.write(cr, uid, ids_to_free, {'reservation_id': False, 'reservation_op_id': False}, context=context)
quant_obj.write(cr, SUPERUSER_ID, ids_to_free, {'reservation_id' : False, 'reservation_op_id': False }, context = context)
def _reserve_quants_ops_move(self, cr, uid, ops, move, qty, create=False, context=None):
"""
@@ -874,7 +875,7 @@ class stock_picking(osv.osv):
if quant[0]: # If quant can be reserved
res_qty -= quant[1]
quant_obj.quants_reserve(cr, uid, quants, move, context=context)
quant_obj.write(cr, uid, [x[0].id for x in quants if x[0]], {'reservation_op_id': ops.id}, context=context)
quant_obj.write(cr, SUPERUSER_ID, [x[0].id for x in quants if x[0]], {'reservation_op_id': ops.id}, context=context)
return res_qty
def rereserve(self, cr, uid, picking_ids, create=False, context=None):
@@ -1690,12 +1691,13 @@ class stock_move(osv.osv):
if move.picking_id and move.picking_id.pack_operation_ids:
quants = quant_obj.quants_get_prefered_domain(cr, uid, move.location_id, move.product_id, qty - move.remaining_qty, domain=dom, prefered_domain=prefered_domain, fallback_domain=fallback_domain, context=context)
quant_obj.quants_move(cr, uid, quants, move, context=context)
for negative_op in negatives[move.id].keys():
ops = ops_obj.browse(cr, uid, negative_op, context=context)
negatives[move.id][negative_op] = quant_obj.quants_move(cr, uid, [(None, negatives[move.id][negative_op])], move,
lot_id = ops.lot_id and ops.lot_id.id or False,
owner_id = ops.owner_id and ops.owner_id.id or False,
package_id = ops.package_id and ops.package_id.id or False, context=context)
if negatives and move.id in negatives:
for negative_op in negatives[move.id].keys():
ops = ops_obj.browse(cr, uid, negative_op, context=context)
negatives[move.id][negative_op] = quant_obj.quants_move(cr, uid, [(None, negatives[move.id][negative_op])], move,
lot_id = ops.lot_id and ops.lot_id.id or False,
owner_id = ops.owner_id and ops.owner_id.id or False,
package_id = ops.package_id and ops.package_id.id or False, context=context)
#Packing:
reserved_ops = list(set([x.reservation_op_id.id for x in move.reserved_quant_ids]))
for ops in ops_obj.browse(cr, uid, reserved_ops, context=context):
+41 -35
View File
@@ -591,7 +591,6 @@
<button name="action_assign" states="confirmed" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="force_assign" states="confirmed" string="Force Availability" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="do_partial" states="assigned" string="Transfer Done" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
<button name="do_rereserve" string="ReReserve from Operations" groups="stock.group_stock_user" type="object" attrs="{'invisible': ['|',('pack_operation_exist', '=', False),('state','!=','assigned')]}"/>
<button name="do_prepare_partial" string="Partial Transfer" groups="stock.group_stock_user" type="object" class="oe_highlight" attrs="{'invisible': ['|',('pack_operation_exist', '=', True),('state','!=','assigned')]}"/>
<button name="%(act_stock_return_picking)d" string="Reverse Transfer" states="done" type="action" groups="base.group_user"/>
<button name="action_cancel" states="assigned,confirmed,draft" string="Cancel Transfer" groups="base.group_user" type="object"/>
@@ -610,16 +609,18 @@
</group>
<group>
<field name="date"/>
<field name="min_date" attrs="{'invisible': [('min_date','=',False)]}"/>
<field name="min_date"/>
<field name="origin" placeholder="e.g. PO0032" class="oe_inline"/>
</group>
</group>
<notebook>
<page string="Products">
<separator string="Expected Quantities" attrs="{'invisible': [('pack_operation_exist', '=', False)]}"/>
<field name="move_lines" context="{'address_in_id': partner_id, 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree', 'default_picking_type_id': picking_type_id}"/>
<separator string="In Process Quantities" attrs="{'invisible': [('pack_operation_exist', '=', False)]}"/>
<field name="pack_operation_exist" invisible="1"/>
<button name="action_pack" string="Create Package" type="object" attrs="{'invisible': ['|',('pack_operation_exist', '=', False),('state', 'not in', ('draft','assigned','confirmed'))]}"
groups="stock.group_tracking_lot"/>
<button name="do_split" string="Split" groups="base.group_no_one" type="object" attrs="{'invisible': ['|',('pack_operation_exist', '=', False),('state','!=','assigned')]}"/>
<button name="action_pack" string="Create Package" type="object" attrs="{'invisible': ['|',('pack_operation_exist', '=', False),('state', 'not in', ('draft','assigned','confirmed'))]}"/>
<button name="do_split" string="Create Draft Backorder" groups="base.group_no_one" type="object" attrs="{'invisible': ['|',('pack_operation_exist', '=', False),('state','!=','assigned')]}"/>
<field name="pack_operation_ids" attrs="{'invisible': [('pack_operation_exist', '=', False)]}">
<tree editable="top">
<field name="product_id"/>
@@ -631,8 +632,6 @@
<field name="result_package_id" groups="stock.group_tracking_lot"/>
</tree>
</field>
<separator string="Expected Quantities"/>
<field name="move_lines" context="{'address_in_id': partner_id, 'form_view_ref':'view_move_picking_form', 'tree_view_ref':'view_move_picking_tree', 'default_picking_type_id': picking_type_id}"/>
<field name="note" placeholder="Add an internal note..." class="oe_inline"/>
</page>
<page string="Additional Info">
@@ -869,7 +868,6 @@
<field name="scrapped" invisible="1"/>
<field name="location_dest_id" groups="stock.group_locations"/>
<field name="state"/>
<field name="remaining_qty" attrs="{'invisible': [('state', '=', 'done')]}"/>
</tree>
</field>
</record>
@@ -889,38 +887,42 @@
</header>
<sheet>
<group>
<group name="main_grp" string="Details">
<field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, False)"/>
<field name="procure_method" attrs="{'readonly': [('state', '!=', 'draft')]}" groups="base.group_no_one"/>
<field name="group_id"/>
<label for="product_uom_qty"/>
<div>
<field name="product_uom_qty"
on_change="onchange_quantity(product_id, product_uom_qty, product_uom, product_uos)"
class="oe_inline"/>
<field name="product_uom" groups="product.group_uom" class="oe_inline"/>
<button name="%(stock.move_scrap)d"
string="Scrap" type="action"
icon="terp-gtk-jump-to-ltr" context="{'scrap': True}"
states="draft,waiting,confirmed,assigned" colspan="1"/>
</div>
<label for="product_uos_qty" groups="product.group_uos"/>
<div groups="product.group_uos">
<field name="product_uos_qty"
on_change="onchange_uos_quantity(product_id, product_uos_qty, product_uos, product_uom)"
class="oe_inline"/>
<field name="product_uos" class="oe_inline"/>
</div>
<field name="name"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<group name="main_grp" string="Details" colspan="4">
<group name="main_grp_col1">
<field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, False)"/>
<label for="product_uom_qty"/>
<div>
<field name="product_uom_qty"
on_change="onchange_quantity(product_id, product_uom_qty, product_uom, product_uos)"
class="oe_inline"/>
<field name="product_uom" groups="product.group_uom" class="oe_inline"/>
<button name="%(stock.move_scrap)d"
string="Scrap" type="action"
icon="terp-gtk-jump-to-ltr" context="{'scrap': True}"
states="draft,waiting,confirmed,assigned" colspan="1"/>
</div>
<field name="name"/>
<label for="product_uos_qty" groups="product.group_uos"/>
<div groups="product.group_uos">
<field name="product_uos_qty"
on_change="onchange_uos_quantity(product_id, product_uos_qty, product_uos, product_uom)"
class="oe_inline"/>
<field name="product_uos" class="oe_inline"/>
</div>
</group>
<group name="main_grp_col1">
<field name="picking_type_id"/>
<field name="picking_priority"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
</group>
<group name="origin_grp" string="Origin">
<field name="origin"/>
<field name="picking_id" domain="[('picking_type_id','=',picking_type_id)]"/>
<field name="picking_type_id"/>
<field name="picking_priority"/>
<field name="location_id" groups="stock.group_locations"/>
<field name="picking_id" domain="[('picking_type_id','=',picking_type_id)]"/>
<field name="create_date" groups="base.group_no_one"/>
<field name="procure_method" attrs="{'readonly': [('state', '!=', 'draft')]}" groups="base.group_no_one"/>
<field name="group_id"/>
</group>
<group name="destination_grp" string="Destination">
<field name="location_dest_id" groups="stock.group_locations"/>
@@ -929,6 +931,9 @@
<field name="date_expected" on_change="onchange_date(date,date_expected)" attrs="{'invisible': [('state', '=', 'done')]}"/>
<field name="date" attrs="{'invisible': [('state', '!=', 'done')]}"/>
</group>
<group name="quants_grp" string="Reserved Quants" colspan="4" groups="base.group_no_one">
<field name="reserved_quant_ids"/>
</group>
</group>
</sheet>
</form>
@@ -981,6 +986,7 @@
<field name="location_id" domain="[('usage','&lt;&gt;','view')]"/>
<field name="location_dest_id" domain="[('usage','=','internal')]" groups="stock.group_locations"/>
</group>
<field name="reserved_quant_ids"/>
</group>
</form>
@@ -103,8 +103,6 @@ class stock_change_product_qty(osv.osv_memory):
'prod_lot_id' : data.lot_id.id
}
inventry_line_obj.create(cr , uid, line_data, context=context)
inventry_obj.action_confirm(cr, uid, [inventory_id], context=context)
inventry_obj.action_done(cr, uid, [inventory_id], context=context)
return {}
+5 -3
View File
@@ -23,6 +23,7 @@ import time
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp import SUPERUSER_ID
import logging
_logger = logging.getLogger(__name__)
@@ -242,7 +243,8 @@ class stock_move(osv.osv):
for q in move.quant_ids:
average_valuation_price += q.qty * q.cost
average_valuation_price = average_valuation_price / move.product_qty
product_obj.write(cr, uid, move.product_id.id, {'standard_price': average_valuation_price}, context=context)
# Write the standard price, as SUPERUSER_ID because a warehouse manager may not have the right to write on products
product_obj.write(cr, SUPERUSER_ID, move.product_id.id, {'standard_price': average_valuation_price}, context=context)
self.write(cr, uid, move.id, {'price_unit': average_valuation_price}, context=context)
def product_price_update_before_done(self, cr, uid, ids, context=None):
@@ -260,8 +262,8 @@ class stock_move(osv.osv):
# Get the standard price
amount_unit = product.price_get('standard_price', context=ctx)[product.id]
new_std_price = ((amount_unit * product_avail) + (move.price_unit * move.product_qty)) / (product_avail + move.product_qty)
# Write the field according to price type field
product_obj.write(cr, uid, [product.id], {'standard_price': new_std_price}, context=context)
# Write the standard price, as SUPERUSER_ID because a warehouse manager may not have the right to write on products
product_obj.write(cr, SUPERUSER_ID, [product.id], {'standard_price': new_std_price}, context=context)
def product_price_update_after_done(self, cr, uid, ids, context=None):
'''
@@ -8,7 +8,10 @@ access_stock_location_path_internal_user,stock location path internal user,model
access_stock_location_path_sale_manager,stock.location.path partner salemanager,model_stock_location_path,base.group_sale_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_stock_location_route,stock.location.route,model_stock_location_route,stock.group_stock_manager,1,0,1,0
access_procurement_rule,procurement.rule.flow,model_procurement_rule,base.group_sale_salesman,1,0,0,0
access_procurement_rule_internal,procurement.rule.flow internal,model_procurement_rule,base.group_user,1,0,0,0
access_stock_putaway_all,stock.putaway all users,model_stock_move_putaway,base.group_user,1,0,0,0
access_product_putaway_all,product.putaway all users,model_product_putaway,base.group_user,1,0,0,0
access_stock_removal_all,product.removal all users,model_product_removal,base.group_user,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
8 access_stock_location_path_sale_manager stock.location.path partner salemanager model_stock_location_path base.group_sale_manager 1 1 1 1
9 access_stock_location_path_stock_user stock.location.path stock user model_stock_location_path stock.group_stock_user 1 1 1 1
10 access_stock_location_path stock.location.path model_stock_location_path base.group_sale_salesman 1 0 0 0
11 access_stock_location_route stock.location.route model_stock_location_route stock.group_stock_manager 1 0 1 0
12 access_procurement_rule procurement.rule.flow model_procurement_rule base.group_sale_salesman 1 0 0 0
13 access_procurement_rule_internal procurement.rule.flow internal model_procurement_rule base.group_user 1 0 0 0
14 access_stock_putaway_all stock.putaway all users model_stock_move_putaway base.group_user 1 0 0 0
15 access_product_putaway_all product.putaway all users model_product_putaway base.group_user 1 0 0 0
16 access_stock_removal_all product.removal all users model_product_removal base.group_user 1 0 0 0
17
+7 -6
View File
@@ -20,6 +20,7 @@
##############################################################################
from openerp.osv import fields, osv
from openerp import SUPERUSER_ID
from datetime import *
from dateutil.relativedelta import relativedelta
from openerp.tools.translate import _
@@ -369,11 +370,11 @@ class stock_warehouse(osv.osv):
vals[values['field']] = location_id
#create new sequences
in_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence in'), 'prefix': vals.get('code', '') + '\IN\\', 'padding': 5}, context=context)
out_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence out'), 'prefix': vals.get('code', '') + '\OUT\\', 'padding': 5}, context=context)
pack_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence packing'), 'prefix': vals.get('code', '') + '\PACK\\', 'padding': 5}, context=context)
pick_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence picking'), 'prefix': vals.get('code', '') + '\PICK\\', 'padding': 5}, context=context)
int_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence internal'), 'prefix': vals.get('code', '') + '\INT\\', 'padding': 5}, context=context)
in_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence in'), 'prefix': vals.get('code', '') + '\IN\\', 'padding': 5}, context=context)
out_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence out'), 'prefix': vals.get('code', '') + '\OUT\\', 'padding': 5}, context=context)
pack_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence packing'), 'prefix': vals.get('code', '') + '\PACK\\', 'padding': 5}, context=context)
pick_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence picking'), 'prefix': vals.get('code', '') + '\PICK\\', 'padding': 5}, context=context)
int_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence internal'), 'prefix': vals.get('code', '') + '\INT\\', 'padding': 5}, context=context)
#create WH
new_id = super(stock_warehouse, self).create(cr, uid, vals=vals, context=context)
@@ -823,7 +824,7 @@ class stock_move(osv.osv):
# Should call different methods here in later versions
# TODO: take care of lots
if putaway.method == 'fixed' and putaway.location_spec_id:
moveputaway_obj.create(cr, uid, {'move_id': move.id,
moveputaway_obj.create(cr, SUPERUSER_ID, {'move_id': move.id,
'location_id': putaway.location_spec_id.id,
'quantity': move.product_uom_qty}, context=context)
return True
@@ -19,10 +19,10 @@
#
##############################################################################
#from . import test_multicompany
#
#checks = [
# test_multicompany,
#]
from . import test_multicompany
checks = [
test_multicompany,
]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -38,6 +38,7 @@ class TestStockMulticompany(common.TransactionCase):
model, group_user_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user')
model, group_stock_manager_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'group_stock_manager')
model, company_2_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'res_company_2')
self.company_2_id = company_2_id
self.multicompany_user_id = self.res_users.create(cr, uid,
{'name': 'multicomp', 'login': 'multicomp',
'groups_id': [(6, 0, [group_user_id, group_stock_manager_id])],
@@ -47,40 +48,25 @@ class TestStockMulticompany(common.TransactionCase):
"""check no error on getting default stock.move values in multicompany setting"""
cr, uid, context = self.cr, self.multicompany_user_id, {}
fields = ['location_id', 'location_dest_id']
for type in ('in', 'internal', 'out'):
context['picking_type'] = type
defaults = self.stock_move.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context)
new_warehouse_id = self.registry('stock.warehouse').create(cr, uid, {'name':'DemoWH_MultiComp','reception_steps':'three_steps', 'delivery_steps' : 'pick_pack_ship', 'company_id':self.company_2_id,'code':'dmwh'}, context=context)
warehouse = self.registry('stock.warehouse').browse(cr, uid, new_warehouse_id, context=context)
for type in ('in', 'int', 'out'):
type_id = warehouse[type + '_type_id'].id
context['default_picking_type_id'] = type_id
defaults = self.stock_move.default_get(cr, uid, ['location_id', 'location_dest_id','picking_type_id'], context=context)
if defaults and defaults['picking_type_id']:
def_type = self.registry('stock.picking.type').browse(cr,uid,defaults['picking_type_id'],context).code_id
else:
assert False, "Picking type undefined "
for field in fields:
if defaults.get(field):
try:
self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context)
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)
self.assertEqual(defaults['type'], type, "wrong move type")
def test_10_multicompany_onchange_move_type(self):
"""check onchange_move_type does not return unreadable in multicompany setting"""
cr, uid, context = self.cr, self.multicompany_user_id, {}
fields = ['location_id', 'location_dest_id']
for type in ('in', 'internal', 'out'):
result = self.stock_move.onchange_move_type(cr, uid, [], type, context)['value']
for field in fields:
if result.get(field):
try:
self.stock_location.check_access_rule(cr, uid, [result[field]], 'read', context)
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)
def test_30_multicompany_default_warehouse_location(self):
"""check default locations for warehouse in multicompany setting"""
cr, uid, context = self.cr, self.multicompany_user_id, {}
fields = ['lot_input_id', 'lot_stock_id', 'lot_output_id']
defaults = self.stock_warehouse.default_get(cr, uid, fields, context)
for field in fields:
if defaults.get(field):
try:
self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context)
except Exception, exc:
assert False, "unreadable default %s: %s" % (field, exc)
self.assertEqual(def_type.lower(), type, "wrong move type")