odoo8 和odoo10区别

Posted 行走在云端

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了odoo8 和odoo10区别相关的知识,希望对你有一定的参考价值。

V8  函数:‘sale_order_count‘: fields.function(_sale_order_count, string=‘# of Sales Order‘, type=‘integer‘),

 

def _sale_order_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict(map(lambda x: (x,0), ids))
# The current user may not have access rights for sale orders
try:
for partner in self.browse(cr, uid, ids, context):
res[partner.id] = len(partner.sale_order_ids) + len(partner.mapped(‘child_ids.sale_order_ids‘))
except:
pass
return res

 

 

V10 函数:sale_order_count = fields.Integer(compute=‘_compute_sale_order_count‘, string=‘# of Sales Order‘)

 

def _compute_sale_order_count(self):
sale_data = self.env[‘sale.order‘].read_group(domain=[(‘partner_id‘, ‘child_of‘, self.ids)],
fields=[‘partner_id‘], groupby=[‘partner_id‘])
# read to keep the child/parent relation while aggregating the read_group result in the loop
partner_child_ids = self.read([‘child_ids‘])
mapped_data = dict([(m[‘partner_id‘][0], m[‘partner_id_count‘]) for m in sale_data])
for partner in self:
# let‘s obtain the partner id and all its child ids from the read up there
item = next(p for p in partner_child_ids if p[‘id‘] == partner.id)
partner_ids = [partner.id] + item.get(‘child_ids‘)
# then we can sum for all the partner‘s child
partner.sale_order_count = sum(mapped_data.get(child, 0) for child in partner_ids)


首先从定义就变化了 function 和compute=‘_compute_sale_order_count‘




v10 调用API比较多

 

以上是关于odoo8 和odoo10区别的主要内容,如果未能解决你的问题,请参考以下文章

Odoo8中“更多”下拉菜单选项指定后台执行代码

odoo8.0条形码改为js方式处理

odoo8 报表页面修改和字体设置

Debian8.3.0下安装Odoo8.0步骤

(47) odoo详细操作手册

(01)odoo8.0_Ubuntu14.04源码安装