123456789101112131415161718192021222324252627282930313233343536373839 |
- # -*- coding: utf-8 -*-
- from odoo.exceptions import ValidationError
- # 得到write方法的vals。只处理修改字段
- # add_detail:明细要修改的数据
- # 参数1:明细ID
- # 参数2:明细字段
- # 参数3:明细字段对应的值
- # add_bill:表头要修改的数据
- # 参数1:表头字段
- # 参数2:表头字段对应的值
- # get:得到write方法需要的vals参数
- class WriteValueHelper(object):
- def __init__(self, detail_field): # 参数:表头中的One2many字段
- self._detail_field = detail_field
- self._detail_dic = {}
- self._bill_dic = {}
- def add_detail(self, detail_id, field, value):
- if detail_id not in self._detail_dic:
- self._detail_dic[detail_id] = {field: value}
- return
- self._detail_dic[detail_id][field] = value
- return
- def add_bill(self, field, value):
- self._bill_dic[field] = value
- return
- def get(self):
- detail = []
- for key in self._detail_dic:
- detail.append([1, key, self._detail_dic[key]])
- if detail:
- self._bill_dic[self._detail_field] = detail
- return self._bill_dic
|