Skip to content

Commit

Permalink
[IMP]release 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodERPJeff committed Oct 5, 2016
1 parent 285ac71 commit 8195331
Show file tree
Hide file tree
Showing 129 changed files with 624 additions and 1,202 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@ python:
- "2.7"

env:
- VERSION="master" ODOO_REPO="osbzr/openobject" LINT_CHECK="0"
- VERSION="master" ODOO_REPO="osbzr/base" LINT_CHECK="0"


virtualenv:
system_site_packages: true

install:
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- git clone https://github.com/GoodERPJeff/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
- pip install xlrd
- pip install xlutils
- pip install docxtpl

script:
- travis_run_tests
Expand Down
28 changes: 14 additions & 14 deletions asset/asset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

from openerp import models, fields, api
import openerp.addons.decimal_precision as dp
from openerp.exceptions import except_orm, ValidationError
from odoo import models, fields, api
import odoo.addons.decimal_precision as dp
from odoo.exceptions import UserError, ValidationError
from datetime import datetime

# 字段只读状态
Expand Down Expand Up @@ -129,15 +129,15 @@ def onchange_bank_account(self):
@api.one
def _wrong_asset_done(self):
if self.state == 'done':
raise except_orm(u'错误', u'请不要重复审核!')
raise UserError(u'错误', u'请不要重复审核!')
if self.period_id.is_closed:
raise except_orm(u'错误', u'该会计期间已结账!不能审核')
raise UserError(u'错误', u'该会计期间已结账!不能审核')
if self.cost <= 0:
raise except_orm(u'错误', u'金额必须大于0!')
raise UserError(u'错误', u'金额必须大于0!')
if self.tax < 0:
raise except_orm(u'错误', u'税额必须大于0!')
raise UserError(u'错误', u'税额必须大于0!')
if self.depreciation_previous < 0:
raise except_orm(u'错误', u'以前折旧必须大于0!')
raise UserError(u'错误', u'以前折旧必须大于0!')
return

@api.one
Expand Down Expand Up @@ -218,13 +218,13 @@ def asset_done(self):
def asset_draft(self):
''' 反审核固定资产 '''
if self.state == 'draft':
raise except_orm(u'错误', u'请不要重复反审核!')
raise UserError(u'错误', u'请不要重复反审核!')
if self.line_ids :
raise except_orm(u'错误', u'已折旧不能反审核!')
raise UserError(u'错误', u'已折旧不能反审核!')
if self.chang_ids :
raise except_orm(u'错误', u'已变更不能反审核!')
raise UserError(u'错误', u'已变更不能反审核!')
if self.period_id.is_closed:
raise except_orm(u'错误', u'该会计期间已结账!不能反审核')
raise UserError(u'错误', u'该会计期间已结账!不能反审核')
self.state = 'draft'
'''删掉凭证'''
if self.voucher_id:
Expand All @@ -249,7 +249,7 @@ def asset_draft(self):
def unlink(self):
for record in self:
if record.state != 'draft':
raise except_orm(u'错误', u'只能删除草稿状态的固定资产')
raise UserError(u'错误', u'只能删除草稿状态的固定资产')

return super(asset, self).unlink()

Expand Down Expand Up @@ -505,7 +505,7 @@ def create_depreciation(self):

if not vouch_obj.line_ids:
vouch_obj.unlink()
raise except_orm(u'错误', u'本期所有固定资产都已折旧!')
raise UserError(u'错误', u'本期所有固定资产都已折旧!')
vouch_obj.voucher_done()
view = self.env.ref('asset.asset_line_tree')
return {
Expand Down
6 changes: 3 additions & 3 deletions asset/tests/test_asset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from openerp.tests.common import TransactionCase
from openerp.exceptions import except_orm
from odoo.tests.common import TransactionCase
from odoo.exceptions import UserError

class test_asset(TransactionCase):

Expand All @@ -12,7 +12,7 @@ def test_unlink(self):
'''测试删除已审核的固定资产'''
asset = self.asset.copy()
self.asset.asset_done()
with self.assertRaises(except_orm):
with self.assertRaises(UserError):
self.asset.unlink()
# 删除草稿状态的固定资产
asset.unlink()
Expand Down
66 changes: 33 additions & 33 deletions buy/buy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#
##############################################################################

from openerp import fields, models, api
import openerp.addons.decimal_precision as dp
from openerp.exceptions import except_orm
from odoo import fields, models, api
import odoo.addons.decimal_precision as dp
from odoo.exceptions import UserError
from datetime import datetime

# 购货订单审核状态可选值
Expand Down Expand Up @@ -213,7 +213,7 @@ def onchange_discount_rate(self):
def unlink(self):
for order in self:
if order.state == 'done':
raise except_orm(u'错误', u'不能删除已审核的单据')
raise UserError(u'错误', u'不能删除已审核的单据')

return super(buy_order, self).unlink()

Expand Down Expand Up @@ -252,16 +252,16 @@ def generate_payment_order(self):
def buy_order_done(self):
'''审核购货订单'''
if self.state == 'done':
raise except_orm(u'错误', u'请不要重复审核!')
raise UserError(u'错误', u'请不要重复审核!')
if not self.line_ids:
raise except_orm(u'错误', u'请输入产品明细行!')
raise UserError(u'错误', u'请输入产品明细行!')
for line in self.line_ids:
if line.quantity <= 0 or line.price_taxed < 0:
raise except_orm(u'错误', u'产品 %s 的数量和含税单价不能小于0!' % line.goods_id.name)
raise UserError(u'错误', u'产品 %s 的数量和含税单价不能小于0!' % line.goods_id.name)
if self.bank_account_id and not self.prepayment:
raise except_orm(u'警告!', u'结算账户不为空时,需要输入预付款!')
raise UserError(u'警告!', u'结算账户不为空时,需要输入预付款!')
if not self.bank_account_id and self.prepayment:
raise except_orm(u'警告!', u'预付款不为空时,请选择结算账户!')
raise UserError(u'警告!', u'预付款不为空时,请选择结算账户!')
# 采购预付款生成付款单
self.generate_payment_order()
self.buy_generate_receipt()
Expand All @@ -272,9 +272,9 @@ def buy_order_done(self):
def buy_order_draft(self):
'''反审核购货订单'''
if self.state == 'draft':
raise except_orm(u'错误', u'请不要重复反审核!')
raise UserError(u'错误', u'请不要重复反审核!')
if self.goods_state != u'未入库':
raise except_orm(u'错误', u'该购货订单已经收货,不能反审核!')
raise UserError(u'错误', u'该购货订单已经收货,不能反审核!')
else:
# 查找产生的入库单并删除
receipt = self.env['buy.receipt'].search(
Expand Down Expand Up @@ -511,11 +511,11 @@ def onchange_goods_id(self):
'''当订单行的产品变化时,带出产品上的单位、成本价。
在采购订单上选择供应商,自动带出供货价格,没有设置供货价的取成本价格。'''
if not self.order_id.partner_id:
raise except_orm(u'错误', u'请先选择一个供应商!')
raise UserError(u'错误', u'请先选择一个供应商!')
if self.goods_id:
self.uom_id = self.goods_id.uom_id
if not self.goods_id.cost:
raise except_orm(u'错误', u'请先设置商品的成本!')
raise UserError(u'错误', u'请先设置商品的成本!')
self.price_taxed = self.goods_id.cost
for line in self.goods_id.vendor_ids:
if line.vendor_id == self.order_id.partner_id \
Expand Down Expand Up @@ -664,7 +664,7 @@ def create(self, vals):
def unlink(self):
for receipt in self:
if receipt.state == 'done':
raise except_orm(u'错误', u'不能删除已审核的单据')
raise UserError(u'错误', u'不能删除已审核的单据')
move = self.env['wh.move'].search([
('id', '=', receipt.buy_move_id.id)
])
Expand All @@ -676,7 +676,7 @@ def unlink(self):
@api.one
def _wrong_receipt_done(self):
if self.state == 'done':
raise except_orm(u'错误', u'请不要重复审核!')
raise UserError(u'错误', u'请不要重复审核!')
batch_one_list_wh = []
batch_one_list = []
for line in self.line_in_ids:
Expand All @@ -687,30 +687,30 @@ def _wrong_receipt_done(self):
batch_one_list_wh.append((move_line.goods_id.id, move_line.lot))

if (line.goods_id.id, line.lot) in batch_one_list_wh:
raise except_orm(u'错误', u'仓库已存在相同序列号的产品!')
raise UserError(u'错误', u'仓库已存在相同序列号的产品!')

for line in self.line_in_ids:
if line.goods_qty <= 0 or line.price_taxed < 0:
raise except_orm(u'错误', u'产品 %s 的数量和含税单价不能小于0!' % line.goods_id.name)
raise UserError(u'错误', u'产品 %s 的数量和含税单价不能小于0!' % line.goods_id.name)
if line.goods_id.force_batch_one:
batch_one_list.append((line.goods_id.id, line.lot))

if len(batch_one_list) > len(set(batch_one_list)):
raise except_orm(u'错误', u'不能创建相同序列号的产品!')
raise UserError(u'错误', u'不能创建相同序列号的产品!')

for line in self.line_out_ids:
if line.goods_qty <= 0 or line.price_taxed < 0:
raise except_orm(u'错误', u'产品 %s 的数量和含税单价不能小于0!' % line.goods_id.name)
raise UserError(u'错误', u'产品 %s 的数量和含税单价不能小于0!' % line.goods_id.name)

if self.bank_account_id and not self.payment:
raise except_orm(u'警告!', u'结算账户不为空时,需要输入付款额!')
raise UserError(u'警告!', u'结算账户不为空时,需要输入付款额!')
if not self.bank_account_id and self.payment:
raise except_orm(u'警告!', u'付款额不为空时,请选择结算账户!')
raise UserError(u'警告!', u'付款额不为空时,请选择结算账户!')
if self.payment > self.amount:
raise except_orm(u'警告!', u'本次付款金额不能大于折后金额!')
raise UserError(u'警告!', u'本次付款金额不能大于折后金额!')
if (sum(cost_line.amount for cost_line in self.cost_line_ids) !=
sum(line.share_cost for line in self.line_in_ids)):
raise except_orm(u'警告!', u'采购费用还未分摊或分摊不正确!')
raise UserError(u'警告!', u'采购费用还未分摊或分摊不正确!')
return

@api.one
Expand Down Expand Up @@ -950,7 +950,7 @@ def onchange_goods_id(self):
if self.goods_id:
is_return = self.env.context.get('default_is_return')
if not self.goods_id.cost:
raise except_orm(u'错误', u'请先设置商品的成本!')
raise UserError(u'错误', u'请先设置商品的成本!')
# 如果是采购入库单行 或 采购退货单行
if (self.type == 'in' and not is_return) or (self.type == 'out' and is_return):
self.tax_rate = self.env.user.company_id.import_tax_rate
Expand Down Expand Up @@ -1036,7 +1036,7 @@ class buy_adjust(models.Model):
def unlink(self):
for order in self:
if order.state == 'done':
raise except_orm(u'错误', u'不能删除已审核的单据')
raise UserError(u'错误', u'不能删除已审核的单据')

return super(buy_adjust, self).unlink()

Expand All @@ -1049,29 +1049,29 @@ def buy_adjust_done(self):
当新增产品时,则更新原单据及入库单分单明细行。
'''
if self.state == 'done':
raise except_orm(u'错误', u'请不要重复审核!')
raise UserError(u'错误', u'请不要重复审核!')
if not self.line_ids:
raise except_orm(u'错误', u'请输入产品明细行!')
raise UserError(u'错误', u'请输入产品明细行!')
for line in self.line_ids:
if line.price_taxed < 0:
raise except_orm(u'错误', u'产品含税单价不能小于0!')
raise UserError(u'错误', u'产品含税单价不能小于0!')
buy_receipt = self.env['buy.receipt'].search(
[('order_id', '=', self.order_id.id),
('state', '=', 'draft')])
if not buy_receipt:
raise except_orm(u'错误', u'采购入库单已全部入库,不能调整')
raise UserError(u'错误', u'采购入库单已全部入库,不能调整')
for line in self.line_ids:
origin_line = self.env['buy.order.line'].search(
[('goods_id', '=', line.goods_id.id),
('attribute_id', '=', line.attribute_id.id),
('order_id', '=', self.order_id.id)])
if len(origin_line) > 1:
raise except_orm(u'错误', u'要调整的商品%s在原始单据中不唯一' % line.goods_id.name)
raise UserError(u'错误', u'要调整的商品%s在原始单据中不唯一' % line.goods_id.name)
if origin_line:
origin_line.quantity += line.quantity # 调整后数量
origin_line.note = line.note
if origin_line.quantity < origin_line.quantity_in:
raise except_orm(u'错误', u'%s调整后数量不能小于原订单已入库数量' % line.goods_id.name)
raise UserError(u'错误', u'%s调整后数量不能小于原订单已入库数量' % line.goods_id.name)
elif origin_line.quantity > origin_line.quantity_in:
# 查找出原购货订单产生的草稿状态的入库单明细行,并更新它
move_line = self.env['wh.move.line'].search(
Expand All @@ -1082,7 +1082,7 @@ def buy_adjust_done(self):
move_line.goods_uos_qty = move_line.goods_qty / move_line.goods_id.conversion
move_line.note = line.note
else:
raise except_orm(u'错误', u'商品%s已全部入库,建议新建购货订单' % line.goods_id.name)
raise UserError(u'错误', u'商品%s已全部入库,建议新建购货订单' % line.goods_id.name)
# 调整后数量与已入库数量相等时,删除产生的入库单分单
else:
buy_receipt.unlink()
Expand Down Expand Up @@ -1185,7 +1185,7 @@ def onchange_goods_id(self):
if self.goods_id:
self.uom_id = self.goods_id.uom_id
if not self.goods_id.cost:
raise except_orm(u'错误', u'请先设置商品的成本!')
raise UserError(u'错误', u'请先设置商品的成本!')
self.price_taxed = self.goods_id.cost

@api.one
Expand Down
16 changes: 0 additions & 16 deletions buy/buy_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,27 @@
<openerp>
<data noupdate="1">
<!-- 购货订单序列号 -->
<record id="seq_type_buy_order" model="ir.sequence.type">
<field name="name">Buy Order</field>
<field name="code">buy.order</field>
</record>
<record id="seq_buy_order" model="ir.sequence">
<field name="name">Buy Order</field>
<field name="code">buy.order</field>
<field name="prefix">BO</field>
<field name="padding">5</field>
</record>
<!-- 采购入库单序列号 -->
<record id="seq_type_buy_receipt" model="ir.sequence.type">
<field name="name">Buy Receipt</field>
<field name="code">buy.receipt</field>
</record>
<record id="seq_buy_receipt" model="ir.sequence">
<field name="name">Buy Receipt</field>
<field name="code">buy.receipt</field>
<field name="prefix">WH/IN/</field>
<field name="padding">5</field>
</record>
<!-- 采购退货单序列号 -->
<record id="seq_type_buy_return" model="ir.sequence.type">
<field name="name">Buy Return</field>
<field name="code">buy.return</field>
</record>
<record id="seq_buy_return" model="ir.sequence">
<field name="name">Buy Return</field>
<field name="code">buy.return</field>
<field name="prefix">IN/RETURN/</field>
<field name="padding">5</field>
</record>
<!-- 采购调整单序列号 -->
<record id="seq_type_buy_adjust" model="ir.sequence.type">
<field name="name">Buy Adjust</field>
<field name="code">buy.adjust</field>
</record>
<record id="seq_buy_adjust" model="ir.sequence">
<field name="name">Buy Adjust</field>
<field name="code">buy.adjust</field>
Expand Down
7 changes: 4 additions & 3 deletions buy/report/buy_order_detail.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

import openerp.addons.decimal_precision as dp
from openerp import fields, models, api, tools
import odoo.addons.decimal_precision as dp
from odoo import fields, models, api, tools


class buy_order_detail(models.Model):
Expand All @@ -25,7 +25,8 @@ class buy_order_detail(models.Model):
subtotal = fields.Float(u'价税合计', digits=dp.get_precision('Amount'))
note = fields.Char(u'备注')

def init(self, cr):
def init(self):
cr = self._cr
tools.drop_view_if_exists(cr, 'buy_order_detail')
cr.execute("""
CREATE or REPLACE VIEW buy_order_detail AS (
Expand Down
4 changes: 2 additions & 2 deletions buy/report/buy_order_track.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

import openerp.addons.decimal_precision as dp
from openerp import fields, models, api
import odoo.addons.decimal_precision as dp
from odoo import fields, models, api


class buy_order_track(models.TransientModel):
Expand Down
4 changes: 2 additions & 2 deletions buy/report/buy_payment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

import openerp.addons.decimal_precision as dp
from openerp import fields, models, api
import odoo.addons.decimal_precision as dp
from odoo import fields, models, api


class buy_payment(models.TransientModel):
Expand Down
Loading

0 comments on commit 8195331

Please sign in to comment.