from openerp.osv import fields, osv
import openerp.addons.decimal_precision as dp
+import openerp
class procurement_group(osv.osv):
'''
'name': fields.char('Name', required=True,
help="This field will fill the packing origin and the name of its moves"),
'group_id': fields.many2one('procurement.group', 'Procurement Group'),
- 'action': fields.selection(selection=lambda s, c, u, ctx: s._get_action(c, u, context=ctx),
+ 'action': fields.selection(selection=lambda s, c, u, context: s._get_action(c, u, context),
string='Action', required=True)
}
def _get_action(self, cr, uid, context=None):
from stock import *
import partner
import product
+import procurement
#import stock_fifo_lifo
import report
import wizard
class procurement_rule(osv.osv):
_inherit = 'procurement.rule'
- def _get_action(self, cr, uid, context=context):
+ def _get_action(self, cr, uid, context=None):
result = super(procurement_rule, self)._get_action(cr, uid, context=context)
return result + [('move','Move From Another Location')]
_columns = {
- 'location_id': fields.many2one('stock.location', 'Destination Location')
+ 'location_id': fields.many2one('stock.location', 'Destination Location'),
'location_src_id': fields.many2one('stock.location', 'Source Location',
help="Source location is action=move")
}
class procurement_order(osv.osv):
_inherit = "procurement.order"
_columns = {
- 'location_id': fields.many2one('stock.location', 'Destination Location')
- 'move_id': fields.many2one('stock.move', 'Move')
+ 'location_id': fields.many2one('stock.location', 'Destination Location'),
+ 'move_id': fields.many2one('stock.move', 'Move'),
'move_dest_id': fields.many2one('stock.move', 'Destination Move')
}
def _assign(self, cr, uid, procurement, context=None):
return super(procurement_order, self)._assign(cr, uid, procurement, context=context)
return rule_obj.browse(cr, uid, res[0], context=context)
- def _run_move_create(self, cr, uid, procurement, context=None)
+ def _run_move_create(self, cr, uid, procurement, context=None):
return {
'name': procurement.name,
'company_id': procurement.company_id.id,
}
-# TODO: move this on stock module
-
-class product_removal_strategy(osv.osv):
- _name = 'product.removal'
- _description = 'Removal Strategy'
- _columns = {
- 'categ_ids':fields.one2many('product.category','removal_strategy_id', 'Product Categories', required=True),
- 'method': fields.selection([('fifo', 'FIFO'), ('lifo', 'LIFO')], "Method", required=True),
- }
class product_category(osv.osv):
_inherit = 'product.category'
_columns = {
- 'removal_strategy_id': fields.many2one('product.removal', 'Removal Strategy'),
'property_stock_journal': fields.property(
relation='account.journal',
type='many2one',
<field name="property_stock_valuation_account_id" domain="[('type','<>','view'), ('type','<>','consolidation')]"/>
<field name="property_stock_journal"/>
</group>
- <group name="removal">
- <field name="removal_strategy"/>
- </group>
</group>
</data>
</field>
'scrap_location': False,
}
def get_removal_strategy(self, cr, uid, location, product, context=None):
- categ = product.categ_id
- while (not categ.removal_strategy_id) and categ.parent_id:
- categ = categ.parent_id
- return categ and categ.removal_strategy_id or None
+ return None
+# categ = product.categ_id
+# while (not categ.removal_strategy_id) and categ.parent_id:
+# categ = categ.parent_id
+# return categ and categ.removal_strategy_id or None
#----------------------------------------------------------
# Quants
dp.append(q.id)
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain_preference=dp and [('id', 'in', dp)], context=context)
quant_obj.quants_reserve(cr, uid, quants, move, context=context)
+ #TODO Should have a check to really check it passed
+ sum_of_qua = 0
+ for qua in quants:
+ sum_of_qua += qua[1]
+ if qua >= move.product_uom_qty:
+ done.append(move.id)
self.write(cr, uid, done, {'state': 'assigned'})
- # FP Note: remove this line
- check_assign = action_assign
#
# Cancel move => cancel others move and pickings
Procurement rules
-->
- <record id="procurement_rule_customer" model="procurement.rule">
+ <record id="procurement_rule_customer0" model="procurement.rule">
<field name="name">Output > Customer</field>
<field name="action">move</field>
<field name="location_id" ref="stock_location_customers"/>
<field name="location_src_id" ref="stock_location_output"/>
</record>
- <record id="procurement_rule_customer" model="procurement.rule">
+ <record id="procurement_rule_customer1" model="procurement.rule">
<field name="name">Stock > Output</field>
<field name="action">move</field>
<field name="location_id" ref="stock_location_output"/>
</xpath>
<xpath expr="/form/header//button[@name='draft_validate']" position="replace">
<button name="draft_validate" states="draft" string="Confirm & Deliver" type="object" class="oe_highlight"/>
- <button name="check_assign" states="confirmed" string="Check Availability" type="object" class="oe_highlight"/>
+ <button name="action_assign" states="confirmed" string="Check Availability" type="object" class="oe_highlight"/>
</xpath>
<xpath expr="/form/header//button[@name='action_process']" position="replace">
<button name="action_process" states="assigned" string="Deliver" type="object" class="oe_highlight"/>
'product_id': move.product_id.id,
'quantity': move.product_qty - move.remaining_qty if move.state == 'assigned' else 0,
'product_uom': move.product_uom.id,
- 'lot_id': move.lot_id.id,
'move_id': move.id,
'location_id': move.location_id.id,
'location_dest_id': move.location_dest_id.id,
""",
'author': 'OpenERP SA',
'images': ['images/pulled_flow.jpeg','images/pushed_flow.jpeg'],
- 'depends': ['procurement','stock','sale'],
+ 'depends': ['procurement','stock'],
'data': ['stock_location_view.xml', 'security/stock_location_security.xml', 'security/ir.model.access.csv'],
'demo': [
'stock_location_demo_cpu1.xml',
-id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink\r
-access_product_pulled_flow_user,product_pulled_flow user,model_product_pulled_flow,stock.group_stock_user,1,0,0,0\r
-access_product_pulled_flow_manager,product_pulled_flow manager,model_product_pulled_flow,stock.group_stock_manager,1,1,1,1\r
-access_product_pulled_flow_salemanager,product_pulled_flow salemanager,model_product_pulled_flow,base.group_sale_manager,1,1,1,1\r
-access_product_pulled_flow_stock_manager,product_pulled_flow stock manager,model_product_pulled_flow,stock.group_stock_manager,1,1,1,1\r
-access_stock_location_path_user,stock location path user,model_stock_location_path,stock.group_stock_user,1,0,0,0\r
-access_stock_location_path_internal_user,stock location path internal user,model_stock_location_path,base.group_user,1,0,0,0\r
-access_stock_location_path_sale_manager,stock.location.path partner salemanager,model_stock_location_path,base.group_sale_manager,1,1,1,1\r
-access_stock_location_path_stock_user,stock.location.path stock user,model_stock_location_path,stock.group_stock_user,1,1,1,1\r
-access_stock_location_path,stock.location.path,model_stock_location_path,base.group_sale_salesman,1,0,0,0\r
-access_product_pulled_flow,product.pulled.flow,model_product_pulled_flow,base.group_sale_salesman,1,0,0,0\r
-access_product_pulled_flow_internal,product.pulled.flow internal,model_product_pulled_flow,base.group_user,1,0,0,0\r
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_procurement_rule_user,procurement_rule user,model_procurement_rule,stock.group_stock_user,1,0,0,0
+access_procurement_rule_manager,procurement_rule manager,model_procurement_rule,stock.group_stock_manager,1,1,1,1
+access_procurement_rule_salemanager,procurement_rule salemanager,model_procurement_rule,base.group_sale_manager,1,1,1,1
+access_procurement_rule_stock_manager,procurement_rule stock manager,model_procurement_rule,stock.group_stock_manager,1,1,1,1
+access_stock_location_path_user,stock location path user,model_stock_location_path,stock.group_stock_user,1,0,0,0
+access_stock_location_path_internal_user,stock location path internal user,model_stock_location_path,base.group_user,1,0,0,0
+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_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
<!-- multi -->
<record model="ir.rule" id="product_pulled_flow_comp_rule">
<field name="name">product_pulled_flow multi-company</field>
- <field name="model_id" ref="model_product_pulled_flow"/>
+ <field name="model_id" ref="model_procurement_rule"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>
'sequence': fields.integer('Sequence'),
'pull_ids': fields.one2many('procurement.rule', 'route_id', 'Pull Rules'),
'push_ids': fields.one2many('stock.location.path', 'route_id', 'Push Rules'),
- 'journal_id': fields.many2one('stock.journal','Journal'),
}
_defaults = {
'sequence': lambda self,cr,uid,ctx: 0,
vals['stock_journal_id'] = route.journal_id.id
vals['type'] = rule.picking_type
if rule.location_dest_id.id<>move.location_dest_id.id:
- move_obj._push_apply(self, cr, uid, move.id, context):
+ move_obj._push_apply(self, cr, uid, move.id, context)
return move.id
else:
move_id = move_obj.copy(cr, uid, move.id, {
'date': time.strftime('%Y-%m-%d'),
'company_id': rule.company_id.id,
'date_expected': newdate,
- )
+ })
move_obj.write(cr, uid, [move.id], {
'move_dest_id': move_id,
})
return move_id
-class procurement.rule(osv.osv):
+class procurement_rule(osv.osv):
_inherit = 'procurement.rule'
_columns = {
'route_id': fields.many2one('stock.location.route', 'Route',
help="If route_id is False, the route is global"),
'delay': fields.integer('Number of Hours'),
- 'route_id': fields.many2one('stock.location.route', 'Route'),
'procure_method': fields.selection([('make_to_stock','Make to Stock'),('make_to_order','Make to Order')], 'Procure Method', required=True, help="'Make to Stock': When needed, take from the stock or wait until re-supplying. 'Make to Order': When needed, purchase or produce for the procurement request."),
'type_proc': fields.selection([('produce','Produce'),('buy','Buy'),('move','Move')], 'Type of Procurement', required=True),
'partner_address_id': fields.many2one('res.partner', 'Partner Address'),
class procurement_order(osv.osv):
+ _inherit = 'procurement.order'
+
def _run_move_create(self, cr, uid, procurement, move, context=None):
d = super(procurement_order, self)._run_move_create(cr, uid, procurement, move, context=context)
newdate = (datetime.strptime(move.date, '%Y-%m-%d %H:%M:%S') - relativedelta(days=rule.delay or 0)).strftime('%Y-%m-%d %H:%M:%S')
d.update({
'date_planned': newdate,
- 'procure_method': rule.procure_method,
+ 'procure_method': procurement.rule_id.procure_method,
})
return d
# TODO: move this on stock module
class product_removal_strategy(osv.osv):
- _inherit = 'product.removal'
+ _name = 'product.removal'
+ _description = 'Removal Strategy'
_order = 'sequence'
_columns = {
+ 'product_categ_id': fields.many2one('product.removal', 'Category', required=True),
'sequence': fields.integer('Sequence'),
- 'location_id': fields.many2one('stock.location', 'Locations'),
+ 'location_id': fields.many2one('stock.location', 'Locations', required=True),
}
class product_product(osv.osv):
<field name="usage">internal</field>
<field name="chained_location_type">none</field>
<field name="name">Quality Control</field>
- <field name="chained_auto_packing">manual</field>
</record>
<record id="stock_location_path_4" model="stock.location.path">
<field model="stock.location" name="location_from_id" search="[('name', '=', u'Input')]"/>
<field name="product_id" ref="product.product_product_10"/>
<field name="auto">manual</field>
<field name="invoice_state">none</field>
- <field name="journal_id" ref="stock_journal_quality"/>
<field name="name">Store in Shelf</field>
<field eval="5" name="delay"/>
<field name="location_dest_id" ref="stock.stock_location_14"/>
<field name="picking_type">internal</field>
</record>
- <record id="product_pulled_flow_l0" model="product.pulled.flow">
+ <record id="product_pulled_flow_l0" model="procurement.rule">
<field name="product_id" ref="product.product_product_9"/>
<field name="location_src_id" ref="stock.stock_location_intermediatelocation0"/>
<field name="location_id" ref="stock.stock_location_shop0"/>
<field name="procure_method">make_to_order</field>
<field name="picking_type">in</field>
<field name="name">Receive from Warehouse</field>
+ <field name="action">move</field>
</record>
- <record id="product_pulled_flow_l1" model="product.pulled.flow">
+ <record id="product_pulled_flow_l1" model="procurement.rule">
<field name="product_id" ref="product.product_product_9"/>
<field name="location_id" ref="stock.stock_location_intermediatelocation0"/>
<field name="location_src_id" ref="stock.stock_location_stock"/>
<field name="procure_method">make_to_stock</field>
<field name="picking_type">out</field>
<field name="name">Deliver Shop</field>
+ <field name="action">move</field>
</record>
<record id="stock_warehouse_orderpoint_shop1_cpu1" model="stock.warehouse.orderpoint">
<field name="product_max_qty">20.0</field>
<field name="warehouse_id" ref="stock.stock_warehouse_shop0"/>
<field name="location_id" ref="stock.stock_location_shop0"/>
<field name="product_id" ref="product.product_product_9"/>
+ <field name="action">move</field>
</record>
</data>
name: Gate A
usage: internal
location_id: location_dispatch_zone
- chained_journal_id: journal_gate_a
- chained_location_type: customer
- chained_auto_packing: manual
- chained_picking_type: out
-
!record {model: stock.location, id: location_pack_zone}:
name: Pack Zone
usage: internal
location_id: location_order
- chained_journal_id: journal_pack
- chained_location_id: location_gate_a
- chained_location_type: fixed
- chained_auto_packing: manual
- chained_picking_type: internal
-
!record {model: stock.location, id: location_gate_b}:
name: Gate B
!record {model: stock.location.path, id: push_pick}:
name: Pick List
product_id: product.product_product_10
- journal_id: journal_pick
location_from_id: stock.stock_location_output
location_dest_id: location_pack_zone
picking_type: internal
- auto: transparent
<field name="name"/>
<field name="location_id" attrs="{'required': [('type_proc', '=', 'move')]}"/>
<field name="type_proc"/>
- <field name="journal_id"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
<form string="Pulled Paths">
<field name="procure_method"/>
<field name="cancel_cascade"/>
<field name="invoice_state"/>
- <field name="journal_id"/>
</group>
</form>
</field>
<field name="location_dest_id"/>
<field name="auto"/>
<field name="delay"/>
- <field name="journal_id"/>
<field name="picking_type"/>
<field name="invoice_state"/>
<field name="company_id" groups="base.group_multi_company"/>