日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

openerp学习笔记 domain 的应用

發布時間:2024/4/17 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 openerp学习笔记 domain 的应用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.在Action中定義,domain用于對象默認的搜索條件:

示例:

<record id="action_orders" model="ir.actions.act_window"><field name="name">Sales Orders</field><field name="type">ir.actions.act_window</field><field name="res_model">sale.order</field><field name="view_type">form</field><field name="view_mode">tree,form,calendar,graph</field><field name="search_view_id" ref="view_sales_order_filter"/><field name="context">{}</field><field name="domain">[('state','not in',('draft','sent','cancel'))]</field><field name="help" type="html"><p class="oe_view_nocontent_create">Click to create a quotation that can be converted into a salesorder.</p><p>OpenERP will help you efficiently handle the complete sales flow:quotation, sales order, delivery, invoicing and payment.</p></field></record> View Code

其中:

?<field name="domain">[('state','not in',('draft','sent','cancel'))]</field>

定義了打開訂單窗口時僅搜索不處于?('draft','sent','cancel') 三種狀態的訂單。

?

2.在對象(或視圖)的關聯字段(many2one和many2many類型字段)中定義,字段值是關聯表的id,domain用于過濾關聯表的記錄:

示例:

_name = 'sale.order.line'_description = 'Sales Order Line'_columns = {'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}),'name': fields.text('Description', required=True, readonly=True, states={'draft': [('readonly', False)]}),'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of sales order lines."),'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True),'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),'invoiced': fields.function(_fnct_line_invoiced, string='Invoiced', type='boolean',store={'account.invoice': (_order_lines_from_invoice, ['state'], 10),'sale.order.line': (lambda self,cr,uid,ids,ctx=None: ids, ['invoice_lines'], 10)}),'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True, states={'draft': [('readonly', False)]}),'type': fields.selection([('make_to_stock', 'from stock'), ('make_to_order', 'on order')], 'Procurement Method', required=True, readonly=True, states={'draft': [('readonly', False)]},help="From stock: When needed, the product is taken from the stock or we wait for replenishment.\nOn order: When needed, the product is purchased or produced."),'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute= dp.get_precision('Account')),'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes', readonly=True, states={'draft': [('readonly', False)]}),'address_allotment_id': fields.many2one('res.partner', 'Allotment Partner',help="A partner to whom the particular product needs to be allotted."),'product_uom_qty': fields.float('Quantity', digits_compute= dp.get_precision('Product UoS'), required=True, readonly=True, states={'draft': [('readonly', False)]}),'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True, readonly=True, states={'draft': [('readonly', False)]}),'product_uos_qty': fields.float('Quantity (UoS)' ,digits_compute= dp.get_precision('Product UoS'), readonly=True, states={'draft': [('readonly', False)]}),'product_uos': fields.many2one('product.uom', 'Product UoS'),'discount': fields.float('Discount (%)', digits_compute= dp.get_precision('Discount'), readonly=True, states={'draft': [('readonly', False)]}),'th_weight': fields.float('Weight', readonly=True, states={'draft': [('readonly', False)]}),'state': fields.selection([('cancel', 'Cancelled'),('draft', 'Draft'),('confirmed', 'Confirmed'),('exception', 'Exception'),('done', 'Done')], 'Status', required=True, readonly=True,help='* The \'Draft\' status is set when the related sales order in draft status. \\n* The \'Confirmed\' status is set when the related sales order is confirmed. \\n* The \'Exception\' status is set when the related sales order is set as exception. \\n* The \'Done\' status is set when the sales order line has been picked. \\n* The \'Cancelled\' status is set when a user cancel the sales order related.'),'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', store=True, string='Customer'),'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', store=True, string='Salesperson'),'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),} View Code

其中:

'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True),

定義了關聯選擇產品時,僅顯示可銷售的產品。

?

3.在搜索視圖中定義,domain用于自定義的搜索條件:

示例:

?

<record id="view_sales_order_filter" model="ir.ui.view"><field name="name">sale.order.list.select</field><field name="model">sale.order</field><field name="arch" type="xml"><search string="Search Sales Order"><field name="name" string="Sales Order" filter_domain="['|',('name','ilike',self),('client_order_ref','ilike',self)]"/><filter icon="terp-mail-message-new" string="Unread Messages" name="message_unread" domain="[('message_unread','=',True)]"/><separator/><filter icon="terp-document-new" string="Quotations" name="draft" domain="[('state','in',('draft','sent'))]" help="Sales Order that haven't yet been confirmed"/><filter icon="terp-check" string="Sales" name="sales" domain="[('state','in',('manual','progress'))]"/><filter icon="terp-dolar_ok!" string="To Invoice" domain="[('state','=','manual')]" help="Sales Order ready to be invoiced"/><filter icon="terp-dolar_ok!" string="Done" domain="[('state','=','done')]" help="Sales Order done"/><separator/><filter string="My Sales Orders" domain="[('user_id','=',uid)]" help="My Sales Orders" icon="terp-personal" name="my_sale_orders_filter"/><field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/><field name="user_id"/><field name="project_id"/><group expand="0" string="Group By..."><filter string="Customer" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/><filter string="Salesperson" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/><filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/><filter string="Order Date" icon="terp-go-month" domain="[]" context="{'group_by':'date_order'}"/></group></search></field></record> View Code

?

其中:

<field name="name" string="Sales Order" filter_domain="['|',('name','ilike',self),('client_order_ref','ilike',self)]"/>

定義了在搜索視圖中輸入訂單編號時,同時按訂單編號和客戶關聯編號過濾。

<filter string="My Sales Orders" domain="[('user_id','=',uid)]" help="My Sales Orders" icon="terp-personal" name="my_sale_orders_filter"/>

定義了在搜索視圖中選擇"My Sales Orders"標簽時,過濾銷售員是當前登錄用戶的訂單。

?

4.在記錄規則中定義,domain用于定義用戶對對象中記錄訪問的權限:

示例:

<record model="ir.rule" id="sale_order_comp_rule"><field name="name">Sales Order multi-company</field><field name="model_id" ref="model_sale_order"/><field name="global" eval="True"/><field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field></record> View Code

其中:

<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>

定義了用戶僅允許查詢訂單中未指定分公司或訂單中指定的分公司用戶具有訪問權限的銷售訂單。

?

5.domain表達式規則說明:

domain中的單個條件是一個三個元素組成的元組。
第一個是對象的一個column,也就是字段名;
第二個是比較運算符 “=, !=, >, >=, <, <=, like, ilike, in, not in, child_of, parent_left, parent_right“ ;
第三個就是用來比較的值了。
多個條件用“|”(or),“&”(and),“!”(no)邏輯運算符鏈接。
邏輯運算符作為前綴放置于條件前面。“|”與“&”必須兩個條件鏈接,“!”對一個條件取反。默認邏輯運算符為“&”。


舉個例子:

['|', ('project_id.privacy_visibility', '=', 'public'), '&', ('project_id.privacy_visibility', 'in', ['portal', 'followers']), '|', ('message_follower_ids','in', [user.partner_id.id]), ('user_id', '=', user.id), ]

寫個容易看的方式:

[
'|',('project_id.privacy_visibility', '=', 'public'),

 ?'&',('project_id.privacy_visibility', 'in', ['portal', 'followers']),

? ?  ?'|', ('message_follower_ids','in', [user.partner_id.id]),
   ?  ('user_id', '=', user.id),
]


這個例子的意思是:

(('project_id.privacy_visibility', '=', 'public') or
(
('project_id.privacy_visibility', 'in', ['portal', 'followers']) and (('message_follower_ids','in', [user.partner_id.id]) or?('user_id', '=', user.id))))

轉載于:https://www.cnblogs.com/cnshen/p/3189306.html

總結

以上是生活随笔為你收集整理的openerp学习笔记 domain 的应用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 韩国av在线播放 | 国产让女高潮的av毛片 | 99自拍偷拍视频 | www.操 | 小色瓷导航 | 男人的天堂97 | 麻豆成人免费视频 | 凹凸日日摸日日碰夜夜 | 性高跟鞋xxxxhd国产电影 | 国内外成人激情视频 | 91国产视频在线播放 | av在线播放网址 | 四虎免费久久 | 国产传媒在线播放 | 免费看日产一区二区三区 | 狠狠操天天操夜夜操 | 日本性爱视频在线观看 | av国产在线观看 | 淫片在线 | 中国成熟妇女毛茸茸 | 黑丝美女啪啪 | 91丝袜在线| 女人囗交吞精囗述 | 对白刺激theporn | 午夜视频入口 | 中国av一区二区三区 | 宅男的天堂 | 日韩欧美国产一区二区在线观看 | www.成人国产 | 女女百合高h喷汁呻吟玩具 www.亚洲一区 | 色狠狠一区 | 阿娇全套94张未删图久久 | 国产精品精品国产 | 国产精品美女在线 | 插少妇视频 | 337p嫩模大胆色肉噜噜噜 | 国产香蕉视频在线观看 | 亚洲精品一区二区三区新线路 | 青青草原国产在线 | 国内精品视频在线观看 | 久久久久久久久久99 | 成人久久精品 | 亚洲精品在线视频免费观看 | 成人午夜sm精品久久久久久久 | 国产欧美综合视频 | 蜜桃视频一区二区在线观看 | 久久国产一区二区 | 国产高清一区二区三区 | 好大好舒服视频 | 国产三级日本三级在线播放 | 欧美性受xxxx黑人xyx | 日韩亚洲国产欧美 | 国产精品自产拍 | 亚洲春色另类 | 久久精品国产亚洲av麻豆 | 蜜桃av乱码一区二区三区 | aaa黄色大片 | 国产69精品久久久久999小说 | 国产午夜三级一区二区三 | 欧美精品亚洲 | 99福利视频导航 | 久久精品免费在线 | 韩国19主播内部福利vip | 成年人视频在线播放 | 日本丰满少妇做爰爽爽 | 国产亚洲精品久久久久动 | 亚洲综合网在线观看 | 国产在线拍揄自揄拍无码 | 亚洲一区二区三区免费视频 | aaaa视频| 中文字幕9 | 亚洲精品第二页 | 在线岛国 | 日本天堂一区 | 欧美大片免费 | 免费av小说 | 日本夫妻性生活视频 | 一区二区三区亚洲精品 | 亚洲欧美日本在线观看 | 日本a级免费| 一道本在线观看 | 国产资源av | 99视屏| 成人精品一区二区三区中文字幕 | 青青草97国产精品免费观看 | 国产又粗又长又黄的视频 | 黄色片在线观看免费 | 激情欧美日韩 | 亚洲人成无码www久久久 | 播放毛片| 边啃奶头边躁狠狠躁 | 奇米色影视 | a猛片| 免费无码av片在线观看 | 国产欧美日韩在线视频 | 成人爽爽视频 | 国产亚洲一区二区三区在线观看 | 禁止18在线观看 | 亚洲一区免费 |