@api.multi
def create_order_sale(self):
""""""
stage_list = []
for order in self.project_id.type_ids:
stage_list.append((order.id, order.now_step))
stage_dict = dict(stage_list)
same_id = []
now_stage_step = self.stage_id.now_step
#对字典进行判断for k, v in stage_dict.items():
if k > self.stage_id.id and v == now_stage_step:
cost_lines = []
if (self.search_count([('partner_task_id', '=', self.id), ('stage_id', '=', k)])) > 0:
continue
else:
task_vals={}
stage_lines=self.env['project.task.type'].browse(k)
task_vals = {
'name': self.name + stage_lines.name,'stage_id': k,
'project_id': self.project_id.id,
'execute_id': stage_lines.execute_id.id
}
#明细表数据:
task_vals['line_id'] = [(0, 0, {
'type_id': k,
'cost_id': i.id,
'name': i.name,
'price': 0,
'paid': 0,
}) for i in stage_lines.sale_cost_id]
print ('sale_vals',task_vals)
self.env['sale.task'].sudo().create(task_vals)
控制按钮显示:
sale_btn_show=fields.Boolean(u'是否显示销售按钮',compute='_compute_show_btn')
@api.one
@api.depends('partner_id.name', 'partner_id.is_company')
def _compute_show_btn(self):
sale_btn_show = False
if self.partner_id.is_company:
self.pname = (self.partner_id.name or "").upper()
sale_btn_show = True
else:
self.pname = self.partner_id.name
self.sale_btn_show = sale_btn_show
心有猛虎,细嗅蔷薇