# 初始化一个变量用来记录产品类型
line_type = ''
# 循环明细行
for product in self.options:
# 拿到该明细行的产品类型
product_type = product.product_id.type
# 如果产品类型为 服务或者可库存的时候
if product_type in ['service', 'product']:
# 判断初始化的变量有没有值
if line_type:
# 如果有值,就判断是不是和第一种状态一致。
if product_type != line_type:
# 如果存在两种状态,就报错
raise Warning("销售订单不能既有'服务商品',又存在'可库存产品'")
else:
# 如果没有值就把第一种状态给这个变量
line_type = product_type
@api.multi
def write(self, vals):
sales_person = self.user_id.id
res = super(BelstarSaleOrderExtend, self).write(vals)
if vals.has_key('user_id'):
sales_person = vals['user_id']
section_ids = self.env['crm.case.section'].search(
['|', '|', '|', ('user_id', '=', self.create_uid.id), ('user_id', '=', sales_person),
('member_ids', 'in', [self.create_uid.id]), ('member_ids', 'in', [sales_person])])
values = self._calc_section(section_ids)
if len(values['section_leader_ids']) > 0:
vals['section_leader_ids'] = [(4, values['section_leader_ids'])]
else:
raise Warning('Can not find your sales team, please check with your sales team leader.')
if len(values['section_member_ids']) > 0:
vals['section_member_ids'] = [(4, values['section_member_ids'])]
else:
raise Warning('Can not find your sales team, please check with your sales team leader.')
line_type = ''
for product in self.options:
product_type = product.product_id.type
# if product_type in ['service', 'product']:
if product_type in ['service']:
if line_type:
if product_type != line_type and vals['order_policy'] == 'picking':
raise Warning("当'其他信息'中的'创建发票'选择'基于交货单时',"
"'推荐的产品'中的产品不能存在产品类型为'服务'的产品")
else:
line_type = product_type
return res
# return super(BelstarSaleOrderExtend, self).write(vals) @api.model
def create(self, vals):
res = super(BelstarSaleOrderExtend, self).create(vals)
section_ids = self.env['crm.case.section'].search(
['|', ('user_id', '=', self._uid), ('member_ids', 'in', [self._uid])])
values = self._calc_section(section_ids)
if len(values['section_leader_ids']) > 0:
vals['section_leader_ids'] = [(4, values['section_leader_ids'])]
else:
raise Warning('Can not find your sales team, please check with your sales team leader.')
if len(values['section_member_ids']) > 0:
vals['section_member_ids'] = [(4, values['section_member_ids'])]
else:
raise Warning('Can not find your sales team, please check with your sales team leader.')
line_type = ''
for product in res.options:
product_type = product.product_id.type
# if product_type in ['service', 'product']:
if product_type == 'service' and vals['order_policy'] == 'picking':
raise Warning("当'其他信息'中的'创建发票'选择'基于交货单时',"
"'推荐的产品'中的产品不能存在产品类型为'服务'的产品")
# if line_type:
# if product_type != line_type and vals['order_policy'] == 'picking':
# raise Warning("当'其他信息'中的'创建发票'选择'基于交货单时',"
# "'推荐的产品'中的产品不能既有'服务商品',又存在'可库存产品'两种产品类型")
# else:
# line_type = product_type
return res
# return super(BelstarSaleOrderExtend, self).create(vals)
												

最新文章

  1. Batis-iBatis基本操作(增删改查)
  2. H5案例分享:使用JS判断客户端、浏览器、操作系统类型
  3. Bootstrap 模态框(Modal)插件
  4. 理解Javascript的异步等待
  5. linux设置tomcat开机启动
  6. PB11.5创建及调用WebService
  7. 宣布在日本地区正式发布 Windows Azure
  8. 基于Verilog HDL的ADC0809CCN数据采样
  9. 各个浏览器开启CSS Grid Layout的方式
  10. 南邮攻防训练平台逆向第四题WxyVM
  11. 业务开发(一)—— MySQL
  12. Druid、BoneCP、DBCP、C3P0等主流数据库对比
  13. sql 查询优化小计
  14. Python Web开发框架Django
  15. Python基础之re模块(正则表达式)
  16. linux 空间释放,mysql数据库空间释放
  17. [LeetCode] 34. Find First and Last Position of Element in Sorted Array == [LintCode] 61. Search for a Range_Easy tag: Binary Search
  18. nginx源码分析:架构解析
  19. JavaScript:正则表达式 分组
  20. SDWebImage动画加载图片

热门文章

  1. Mongodb系列- java客户端简单使用(CRUD)
  2. Java之Servlet
  3. CentOS 6.5 x64相关安全,优化配置
  4. Python时间,日期,时间戳之间转换,时间转换时间戳,Python时间戳转换时间,Python时间转换时间戳
  5. python 执行sql得到字典格式数据
  6. 游戏开发中IIS常见支持MIME类型文件解析
  7. [Linux 性能调优] 网卡中断与CPU的绑定问题
  8. C++ 函数模板的返回类型如何确定?
  9. JVM:Java常见内存溢出异常分析
  10. php -- func_get_args