订单tree 视图显示是否退货
-
正常流程下,销售订单或采购订单,发完货,订单显示完成。如果退了货,从订单看不出任何痕迹。需求出来,如果有退货,提示有退货。
经 总监 提醒,在订单 里加上 function 字段,如 amount_stock_return
_columns = {
'amount_stock_return': fields.function(_amount_stock_return, type='float', string=u'退货金额', multi="amount_stock_return", help="出库单,退货对应销售订单金额")
,'amount_payment_return':fields.function(_amount_payment_return, type='float', string=u'退款金额', multi="amount_payment_return", help="红字发票,付款(即退款)")
}
自定义 _amount_stock_return 和_amount_payment_return 函数,函数中读取想要的数据,
然后在 xml 里
<record model="ir.ui.view" id="sale_order_xyls_tree">
<field name="name">sale.view_order.tree</field>
<field name="type">tree</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree" />
<field name="arch" type="xml">
<!--
<xpath expr="//tree[@string='Sales Orders']" position="attributes">
<attribute colors="grey:state=='cancel';green:amount_stock_return>0;blue:state in ('waiting_date','manual');red:state in ('invoice_except','shipping_except')"/>
</xpath>
-->
<field name="partner_id" position="before">
<field name="shop_id" string="门店"/>
</field>
<field name="amount_total" position="after">
<field name="amount_stock_return" sum="退货合计"/>
</field>
</field>
</record>
本想,如果退货金额大于0 时 变绿色,在xml 没有成功,不知道怎么定位到 修改colors 的地方,暂时 注释
--------------------------------修改--------------------------------------
按照楼下大师指点,改为 正常,感谢大师
<xpath expr="//tree[@string='Sales Orders']" position="attributes">
<attribute name="colors">
grey:state=='cancel';green:amount_stock_return>0;blue:state in ('waiting_date','manual');red:state in ('invoice_except','shipping_except')
</attribute>
</xpath> -
[font=verdana][size=13px] [/size][/font]
<xpath expr="//tree[@string='Sales Orders']" position="attributes"> <attribute colors="grey:state=='cancel';green:amount_stock_return>0;blue:state in ('waiting_date','manual');red:state in ('invoice_except','shipping_except')"/> </xpath>
改成<xpath expr="//tree[@string='Sales Orders']" position="attributes"><br /><attribute name="colors"><br /> grey:state=='cancel';green:amount_stock_return>0;blue:state in ('waiting_date','manual');red:state in ('invoice_except','shipping_except')<br /> </attribute> <br /></xpath>