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 科目 基础对象 ...
随机推荐
- PHP-问题处理Fatal error: Uncaught Error: Call to undefined function simplexml_load_file()
1.问题 今天重新安装了ubuntu,PHP,MySQL,Apache,到测试CMS项目时发生一个错误: Fatal error: Uncaught Error: Call to undefined ...
- Introducing DataFrames in Apache Spark for Large Scale Data Science(中英双语)
文章标题 Introducing DataFrames in Apache Spark for Large Scale Data Science 一个用于大规模数据科学的API——DataFrame ...
- Android设备真实DPI与系统标示DPI——ldpi/mdpi/hdpi/xhdpi/xxhdpi/xxxhdpi
1.设备真实DPI与系统标示DPI 2.drawable允许的标示DPI值 drawable文件的合法名称如下: 3.如何验证 Demo如下,建立不同dpi的drawa ...
- 环境的配置; host 配置地址
1.环境的配置: C:\Windows\System32\drivers\etc 2.如果没有下载host 切记复制etc的文件,在c盘桌面打开,更改后替换 3.可下载host 和fiddle 4.多 ...
- JS 的加密库简介
作为前端,数据提交到后台之前,重要的数据要进行加密一下,虽然已经有 https 等技术,但是增加一道前端的加密还是相对更安全的.虽然,前端的加密很容破解,但是有总比没有强. 尤其是涉及到用户名和密码, ...
- C#学习笔记(34)——委托传值(回忆版)
说明(2018-4-6 20:31:03): 1. 昨天晚上看三层,看完第一天的最后一节,会员的修改和增加,感觉欲仙欲死,果断关机睡觉. 2. 上午搞了半天哈利波特的原版书epub的下载,结果都没发现 ...
- 快速开发项目,用到的工具:UI 设置利器 sketch
需求设计: axaure8.0 tool: teambition/石墨.幕布. 接口管理tool(后端开发接口,pc,m,app使用) https://www.eolinker.com/#/ ui 设 ...
- 【资料下载区】【GMT43相关代码、资料下载地址】更新日期2017/06/28
[GMT43相关文档][更新中...] GMT43原理图(PDF)下载GMT43说明书(PDF)下载GMT43机械结构尺寸(PDF)下载 [GMT43相关例程代码][ARM][更新中...] 基于HA ...
- Win7 vs2017 WDK 1803 1809 驱动开发 出错 KMDF
一.编译出错, 1. 包含头文件出错 解决方案: 需要下载1803 的wdk 最新的1809会出一堆错误 安装程序显示是10.0.17134.1安装完成后是10.0.17134.0 2. Inf2C ...
- windows 10系统 上安装scrapy
1.python的安装(我已安装完) 2.pip的安装(我已安装) 3.安装twisted https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 命令 ...