[IMP] procurments

bzr revid: fp@tinyerp.com-20130630230028-9g4ub7xewy9b7xf6
This commit is contained in:
Fabien Pinckaers 2013-07-01 01:00:28 +02:00
parent bcca9e9652
commit fd369617e4
4 changed files with 83 additions and 61 deletions

View File

@ -38,20 +38,22 @@ class procurement_rule(osv.osv):
def _get_action(self, cr, uid, context=context):
result = super(procurement_rule, self)._get_action(cr, uid, context=context)
return result + [('move','Move From Another Location')]
class procurement_order(osv.osv):
_inherit = "procurement.order"
_columns = {
'location_id': fields.many2one('stock.location', 'Source Location')
'move_id': fields.many2one('stock.move', 'Move')
'move_dest_id': fields.many2one('stock.move', 'Destination Move')
'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 = {
'move_id': fields.many2one('stock.move', 'Move')
'move_dest_id': fields.many2one('stock.move', 'Destination Move')
}
def _run(self, cr, uid, procurement, context=None):
if procurement.rule_id and procurement.rule_id.action == 'move':
if not procurement.location_src_id:
if not procurement.rule_id.location_src_id:
self.message_post(cr, uid, [procurement.id], body=_('No source location defined!'), context=context)
return False
move_obj = self.pool.get('stock.move')
@ -68,8 +70,8 @@ class procurement_order(osv.osv):
or procurement.product_uom.id,
'partner_id': procurement.group_id and procurement.group_id.partner_id and \
procurement.group_id.partner_id.id or False,
'location_id': procurement.location_src_id.id,
'location_dest_id': procurement.location_id.id,
'location_id': procurement.rule_id.location_src_id.id,
'location_dest_id': procurement.rule_id.location_id.id,
'move_dest_id': procurement.move_dest_id and procurement.move_dest_id.id or False,
'cancel_cascade': procurement.rule_id and procurement.rule_id.cancel_cascade or False,
'group_id': procurement.group_id and procurement.group_id.id or False,

View File

@ -30,7 +30,7 @@
<group name="removal">
<field name="removal_strategy"/>
</group>
</group>
</group>
</data>
</field>
</record>
@ -40,15 +40,15 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<group name="delay" position="inside">
<field name="sale_delay" attrs="{'readonly':[('sale_ok','=',False)]}"/>
</group>
<group name="delay" position="after">
<group name="store" string="Storage Location">
<group name="delay" position="inside">
<field name="sale_delay" attrs="{'readonly':[('sale_ok','=',False)]}"/>
</group>
<group name="delay" position="after">
<group name="store" string="Storage Location">
<field name="loc_rack"/>
<field name="loc_row"/>
<field name="loc_case"/>
</group>
<field name="loc_case"/>
</group>
</group>
<page position="after" string="Information">
<page string="Properties">
@ -182,7 +182,7 @@
<field name="context" eval="'{\'search_default_product_id\': [active_id]}'"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to register a reception for this product.
Click to register a reception for this product.
</p><p>
Here you will find the history of all receptions related to
this product, as well as all future receptions you are waiting
@ -235,5 +235,47 @@
</field>
</record>
<record model="ir.ui.view" id="product_form_view_procurement_button">
<field name="name">product.product.procurement</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.view_normal_procurement_locations_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='incoming_qty']" position="after">
<button string="⇒ Request Procurement" name="%(act_make_procurement)d" type="action" class="oe_link"/>
</xpath>
<xpath expr="//div[@name='buttons']" position="inside">
<button string="Orderpoints" name="%(product_open_orderpoint)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}"/>
</xpath>
<xpath expr="//field[@name='cost_method']" position="before">
<field name="procure_method" groups="base.group_user"/>
<field name="supply_method" groups="base.group_user"/>
</xpath>
<xpath expr="//group[@name='general']" position="after" >
<group name="procurement_help" class="oe_grey" col="1" groups="base.group_user">
<p attrs="{'invisible': ['|','|',('type','&lt;&gt;','service'),('procure_method','&lt;&gt;','make_to_stock')]}">
When you sell this service, nothing special will be triggered
to deliver the customer, as you set the procurement method as
'Make to Stock'.
</p>
<p attrs="{'invisible': ['|','|',('type','&lt;&gt;','product'),('procure_method','&lt;&gt;','make_to_stock')]}">
When you sell this product, OpenERP will <b>use the available
inventory</b> for the delivery order.
<br/><br/>
If there are not enough quantities available, the delivery order
will wait for new products. To fulfill the inventory, you should
create others rules like orderpoints.
</p>
<p attrs="{'invisible': ['|','|',('type','&lt;&gt;','consu'),('procure_method','&lt;&gt;','make_to_stock')]}">
When you sell this product, a delivery order will be created.
OpenERP will consider that the <b>required quantities are always
available</b> as it's a consumable (as a result of this, the quantity
on hand may become negative).
</p>
</group>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -110,6 +110,25 @@ watch your stock valuation, and track production lots upstream and downstream (b
<field name="location_id" ref="stock_location_company"/>
</record>
<!--
Procurement rules
-->
<record id="procurement_rule_customer" 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">
<field name="name">Stock > Output</field>
<field name="action">move</field>
<field name="location_id" ref="stock_location_output"/>
<field name="location_src_id" ref="stock_location_stock"/>
</record>
<!--
Properties
-->

View File

@ -1550,8 +1550,8 @@
<!-- Procurements are located in Warehouse menu hierarchy, MRP users should come to Stock application to use it. -->
<menuitem id="menu_stock_sched" name="Schedulers" parent="stock.menu_stock_root" sequence="4" groups="stock.group_stock_manager"/>
<menuitem action="action_compute_schedulers" id="menu_stock_proc_schedulers" parent="menu_stock_sched" sequence="20" groups="stock.group_stock_manager"/>
<menuitem action="procurement_exceptions" id="menu_stock_procurement_action" parent="menu_stock_sched" sequence="50" groups="stock.group_stock_manager"/>
<menuitem action="procurement.action_compute_schedulers" id="menu_stock_proc_schedulers" parent="menu_stock_sched" sequence="20" groups="stock.group_stock_manager"/>
<menuitem action="procurement.procurement_exceptions" id="menu_stock_procurement_action" parent="menu_stock_sched" sequence="50" groups="stock.group_stock_manager"/>
<menuitem id="menu_stock_procurement" name="Automatic Procurements" parent="stock.menu_stock_configuration" sequence="5"/>
<menuitem action="action_orderpoint_form" id="menu_stock_order_points" parent="stock.menu_stock_configuration" sequence="10"/>
@ -1585,47 +1585,6 @@
</field>
</record>
<record model="ir.ui.view" id="product_form_view_procurement_button">
<field name="name">product.product.procurement</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.view_normal_procurement_locations_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='incoming_qty']" position="after">
<button string="⇒ Request Procurement" name="%(act_make_procurement)d" type="action" class="oe_link"/>
</xpath>
<xpath expr="//div[@name='buttons']" position="inside">
<button string="Orderpoints" name="%(product_open_orderpoint)d" type="action" attrs="{'invisible':[('type', '=', 'service')]}"/>
</xpath>
<xpath expr="//field[@name='cost_method']" position="before">
<field name="procure_method" groups="base.group_user"/>
<field name="supply_method" groups="base.group_user"/>
</xpath>
<xpath expr="//group[@name='general']" position="after" >
<group name="procurement_help" class="oe_grey" col="1" groups="base.group_user">
<p attrs="{'invisible': ['|','|',('type','&lt;&gt;','service'),('procure_method','&lt;&gt;','make_to_stock')]}">
When you sell this service, nothing special will be triggered
to deliver the customer, as you set the procurement method as
'Make to Stock'.
</p>
<p attrs="{'invisible': ['|','|',('type','&lt;&gt;','product'),('procure_method','&lt;&gt;','make_to_stock')]}">
When you sell this product, OpenERP will <b>use the available
inventory</b> for the delivery order.
<br/><br/>
If there are not enough quantities available, the delivery order
will wait for new products. To fulfill the inventory, you should
create others rules like orderpoints.
</p>
<p attrs="{'invisible': ['|','|',('type','&lt;&gt;','consu'),('procure_method','&lt;&gt;','make_to_stock')]}">
When you sell this product, a delivery order will be created.
OpenERP will consider that the <b>required quantities are always
available</b> as it's a consumable (as a result of this, the quantity
on hand may become negative).
</p>
</group>
</xpath>
</field>
</record>
</data>
</openerp>