[IMP] purchase: cancellation of a procurement related to a PO + some usability changes

bzr revid: qdp-launchpad@openerp.com-20131022085856-i9m00f1hh0qkrkk9
This commit is contained in:
Quentin (OpenERP) 2013-10-22 10:58:56 +02:00
parent e0b7ff8de6
commit 4d8a5750de
2 changed files with 12 additions and 4 deletions

View File

@ -964,6 +964,12 @@ class purchase_order_line(osv.osv):
supplier_delay = int(supplier_info.delay) if supplier_info else 0
return datetime.strptime(date_order_str, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=supplier_delay)
def action_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
for po_line in self.browse(cr, uid, ids, context=context):
if all([l.state == 'cancel' for l in po_line.order_id.order_line]):
self.pool.get('purchase.order').action_cancel(cr, uid, [po_line.order_id.id], context=context)
def _check_product_uom_group(self, cr, uid, context=None):
group_uom = self.pool.get('ir.model.data').get_object(cr, uid, 'product', 'group_uom')
res = [user for user in group_uom.users if user.id == uid]
@ -1079,12 +1085,13 @@ class procurement_rule(osv.osv):
class procurement_order(osv.osv):
_inherit = 'procurement.order'
_columns = {
'purchase_line_id': fields.many2one('purchase.order.line', 'Purchase Order'),
'purchase_line_id': fields.many2one('purchase.order.line', 'Purchase Order Line'),
'purchase_id': fields.related('purchase_line_id', 'order_id', type='many2one', relation='purchase.order', string='Purchase Order'),
}
def propagate_cancel(self, cr, uid, procurement, context=None):
if procurement.rule_id.action == 'buy' and procurement.purchase_line_id:
self.pool.get('purchase.order.line').write(cr, uid, [procurement.purchase_line_id.id], {'state': 'cancel'}, context=context)
self.pool.get('purchase.order.line').action_cancel(cr, uid, [procurement.purchase_line_id.id], context=context)
return super(procurement_order, self).propagate_cancel(cr, uid, procurement, context=context)
def _run(self, cr, uid, procurement, context=None):

View File

@ -208,7 +208,7 @@
<notebook>
<page string="Products">
<field name="order_line">
<tree string="Purchase Order Lines" editable="bottom">
<tree string="Purchase Order Lines" editable="bottom" colors="grey:state=='cancel'">
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,parent.state,context)"/>
<field name="name"/>
<field name="date_planned"/>
@ -219,6 +219,7 @@
<field name="price_unit"/>
<field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
<field name="price_subtotal"/>
<field name="state" invisible="1"/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">
@ -550,7 +551,7 @@
<field name="inherit_id" ref="procurement.procurement_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='origin']" position="after">
<field name="purchase_line_id"/>
<field name="purchase_id"/>
</xpath>
</field>
</record>