sale.order
# 初始化一个变量用来记录产品类型
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)
sale.order的更多相关文章
- Unable To Import Or Enter Sale Order - ORA-20001: APP-FND-01564: ORACLE error - 1422 in get_seq_info
In this Document Symptoms Cause Solution APPLIES TO: Oracle Order Management - Version 12.0.4 ...
- Odoo 二次开发教程(四)-只读、唯一性验证和ORM方法介绍
一.只读和唯一性验证 只读的设置有两种方法,一种是实在字段定义时设置为只读,第二种是在页面视图中进行设置. 接前例,我们将学生(tech.student)的名字name字段设置成只读. 方法一:字段定 ...
- OpenERP ORM 对象方法列表
OpenERP对象支持的字段类型有,基础类型:char, text, boolean, integer, float, date, time, datetime, binary:复杂类型:select ...
- odoo 人力资源工资计算拓展
默认情况下 odoo工资条的计算只支持一下几种python变量: # payslip: object containing the payslips# employee: hr.employee ob ...
- jbpm的学习 出处http://blog.csdn.net/hxirui/article/details/1221911
jbpm入门例子 分类: opensourse2006-09-14 11:30 37308人阅读 评论(22) 收藏 举报 jbpmhibernate数据库oraclemysqltransition ...
- 那些年我们写过的T-SQL(上篇)
在当今这个多种不同数据库混用,各种不同语言不同框架融合的年代(一切为了降低成本并高效的提供服务),知识点多如牛毛.虽然大部分SQL脚本可以使用标准SQL来写,但在实际中,效率就是一切,因而每种不同厂商 ...
- easyUI框架之学习3--表格datagrid
@model MVCEasyUI.Models.Sale.PageResult<MVCEasyUI.Models.Sale.Order> @{ ViewBag.Title = " ...
- (30)odoo中的快捷标签
* 快捷标签 提供快捷标签是为了简化代码的编码,把复杂的工作封装化 * 找到封装化的源码: openerp/tools/convert.py xml_import self._ ...
- (24)odoo中模型标识汇总
* 设置->技术->数据结构->模型 模型 模型描述 类型 瞬态模型account.account 科目 基础对象 ...
随机推荐
- 找不到指定的 VM 安装:类型 标准 VM,名称 jre7
问题背景是这样 原来使用的是jre7.0.55,后来为了安装使用 layabox IDE ,然后装了jdk_8u144 之后需要切换环境变量 之后java项目调试的时候重新设置了jdk,没问题. 直到 ...
- Effective Java 第三版——70. 对可恢复条件使用检查异常,对编程错误使用运行时异常
Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...
- python itertools 模块讲解
1.介绍itertools 是python的迭代器模块,itertools提供的工具相当高效且节省内存. 使用这些工具,你将能够创建自己定制的迭代器用于高效率的循环. - 无限迭代器 itertool ...
- mysql使用问题记录
Mysql Access denied for user 'root' ERROR 1045 (28000): Access denied for user 'root'@'localhost' (u ...
- 使用DNSPod解析Freenom域名
注册Freenom域名 Freenom官网:http://www.freenom.com Freenom提供的顶级域名包括:tk,ml,ga,cf,gq 申请流程: 注册用户后登陆,然后查询并选择一个 ...
- windows 上搭建gitblit
https://www.cnblogs.com/ucos/p/3924720.htmlhttps://www.cnblogs.com/sumuncle/p/6362697.htmlhttp://www ...
- 【Python】 Numpy极简寻路
[Numpy] 先感叹下最近挖坑越来越多了.. 最近想不自量力地挑战下ML甚至DL.然而我也知道对于我这种半路出家,大学数学也只学了两个学期,只学了点最基本的高数还都忘光了的渣滓来说,难度估计有点大. ...
- C++ 非常量引用无效
/* 非常量引用无效 */ #include <iostream> using namespace std; /* C++标准的规定:非常量的引用不能指向临时对象: 为了防止给常量或临时变 ...
- 必读:Spark与kafka010整合
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/rlnLo2pNEfx9c/article/details/79648890 SparkStreami ...
- YARN 启动后失败退出——没有请求资源——Invalid resource request, no resources request
在ambari-server中修改了yarn的配置,重新启动服务,结果RM启动失败,错误也很奇怪,“不合理的资源请求,没有请求任何资源”!详细如下: -- ::, FATAL resourcemana ...