sale.order
2024-08-31 01:56:56
# 初始化一个变量用来记录产品类型
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)
最新文章
- Batis-iBatis基本操作(增删改查)
- H5案例分享:使用JS判断客户端、浏览器、操作系统类型
- Bootstrap 模态框(Modal)插件
- 理解Javascript的异步等待
- linux设置tomcat开机启动
- PB11.5创建及调用WebService
- 宣布在日本地区正式发布 Windows Azure
- 基于Verilog HDL的ADC0809CCN数据采样
- 各个浏览器开启CSS Grid Layout的方式
- 南邮攻防训练平台逆向第四题WxyVM
- 业务开发(一)—— MySQL
- Druid、BoneCP、DBCP、C3P0等主流数据库对比
- sql 查询优化小计
- Python Web开发框架Django
- Python基础之re模块(正则表达式)
- linux 空间释放,mysql数据库空间释放
- [LeetCode] 34. Find First and Last Position of Element in Sorted Array == [LintCode] 61. Search for a Range_Easy tag: Binary Search
- nginx源码分析:架构解析
- JavaScript:正则表达式 分组
- SDWebImage动画加载图片
热门文章
- Mongodb系列- java客户端简单使用(CRUD)
- Java之Servlet
- CentOS 6.5 x64相关安全,优化配置
- Python时间,日期,时间戳之间转换,时间转换时间戳,Python时间戳转换时间,Python时间转换时间戳
- python 执行sql得到字典格式数据
- 游戏开发中IIS常见支持MIME类型文件解析
- [Linux 性能调优] 网卡中断与CPU的绑定问题
- C++ 函数模板的返回类型如何确定?
- JVM:Java常见内存溢出异常分析
- php -- func_get_args