Skip to content

Commit

Permalink
Merge pull request #1879 from floraXiao/master
Browse files Browse the repository at this point in the history
[FIX]1.审批向导进去所有单据跳过审批的bug,2.不需审批单据自动移除待审批人,3.作废单据时做判断
  • Loading branch information
floraXiao committed Jul 13, 2018
2 parents 3913a35 + a5b30c5 commit 47b9547
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
20 changes: 11 additions & 9 deletions buy/models/buy_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ def _get_buy_money_state(self):
store=True, default=u'未退款',
help=u"采购退货单的退款状态",
index=True, copy=False)
modifying = fields.Boolean(u'差错修改中', default=False,
modifying = fields.Boolean(u'差错修改中', default=False, copy=False,
help=u'是否处于差错修改中')
voucher_id = fields.Many2one('voucher', u'入库凭证', readonly=True,
copy=False,
help=u'入库时产生的入库凭证')
origin_id = fields.Many2one('buy.receipt', u'来源单据')
origin_id = fields.Many2one('buy.receipt', u'来源单据', copy=False)
currency_id = fields.Many2one('res.currency',
u'外币币别',
readonly=True,
Expand Down Expand Up @@ -301,7 +302,6 @@ def _make_payment(self, invoice_id, amount, this_reconcile):
'note': self.note,
'buy_id': self.order_id.id,
})
self.money_order_id = money_order.id
return money_order

def _create_voucher_line(self, account_id, debit, credit, voucher_id, goods_id, goods_qty, partner_id):
Expand Down Expand Up @@ -390,19 +390,21 @@ def buy_receipt_done(self):

# 入库单/退货单 生成结算单
invoice_id = self._receipt_make_invoice()
self.write({
'voucher_id': voucher and voucher.id,
'invoice_id': invoice_id and invoice_id.id,
'state': 'done', # 为保证审批流程顺畅,否则,未审批就可审核
})
# 采购费用产生结算单
self._buy_amount_to_invoice()
# 生成付款单
money_order = False
if self.payment:
flag = not self.is_return and 1 or -1
amount = flag * self.amount
this_reconcile = flag * self.payment
self._make_payment(invoice_id, amount, this_reconcile)
money_order = self._make_payment(invoice_id, amount, this_reconcile)
self.write({
'voucher_id': voucher and voucher.id,
'invoice_id': invoice_id and invoice_id.id,
'money_order_id': money_order and money_order.id,
'state': 'done', # 为保证审批流程顺畅,否则,未审批就可审核
})
# 生成分拆单 FIXME:无法跳转到新生成的分单
if self.order_id and not self.modifying:
# 如果已退货也已退款,不生成新的分单
Expand Down
35 changes: 22 additions & 13 deletions good_process/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ def good_process_refused(self, active_id, active_model):
return_vals = u'已经通过不能拒绝!'
return return_vals, message or ''

def remove_approver(self):
'''移除待审批人'''
manger_row = self.__has_manager__(self.id, self._name)

if (manger_row and manger_row.user_id.id == self.env.uid) or not manger_row:
manger_user = []
if manger_row:
manger_user = [manger_row.user_id.id]
self.__is_departement_manager__(manger_row)
users, can_clean_groups = (self.__get_user_group__(
self.id, self._name, manger_user, self))
self.__remove_approver__(
self.id, self._name, users, can_clean_groups)

def is_current_model(self):
"""检查是否是当前对象"""
action_id = self.env.context.get('params', False) \
Expand All @@ -163,7 +177,9 @@ def is_current_model(self):
if not action_id:
return True
current_model = self.env['ir.actions.act_window'].browse(action_id).res_model
if current_model != self._name:
# 排除good_process.approver是因为从审批向导进去所有单据current_model != self._name导致跳过审批流程
if current_model != self._name and current_model != 'good_process.approver':
self.remove_approver()
return False
else:
return True
Expand Down Expand Up @@ -197,18 +213,11 @@ def write(self, vals):
change_state = vals.get('state', False)

if change_state == 'cancel': # 作废时移除待审批人
model_row = th
manger_row = self.__has_manager__(th.id, th._name)

if (manger_row and manger_row.user_id.id == self.env.uid) or not manger_row:
manger_user = []
if manger_row:
manger_user = [manger_row.user_id.id]
self.__is_departement_manager__(manger_row)
users, can_clean_groups = (self.__get_user_group__(
th.id, th._name, manger_user, model_row))
self.__remove_approver__(
th.id, th._name, users, can_clean_groups)
if not len(th._to_approver_ids) and th._approver_num:
raise ValidationError(u"已审批不可作废")
if len(th._to_approver_ids) < th._approver_num:
raise ValidationError(u"审批中不可作废")
th.remove_approver()

# 已提交,确认时报错
if len(th._to_approver_ids) == th._approver_num and change_state == 'done':
Expand Down
14 changes: 8 additions & 6 deletions sell/models/sell_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,22 +446,24 @@ def sell_delivery_done(self):
voucher = record.create_voucher()
# 发货单/退货单 生成结算单
invoice_id = record._delivery_make_invoice()
record.write({
'voucher_id': voucher and voucher.id,
'invoice_id': invoice_id and invoice_id.id,
'state': 'done', # 为保证审批流程顺畅,否则,未审批就可审核
})
# 销售费用产生结算单
record._sell_amount_to_invoice()
# 生成收款单,并审核
money_order = False
if record.receipt:
flag = not record.is_return and 1 or -1
amount = flag * (record.amount + record.partner_cost)
this_reconcile = flag * record.receipt
money_order = record._make_money_order(
invoice_id, amount, this_reconcile)
money_order.money_order_done()
self.money_order_id = money_order.id

record.write({
'voucher_id': voucher and voucher.id,
'invoice_id': invoice_id and invoice_id.id,
'money_order_id': money_order and money_order.id,
'state': 'done', # 为保证审批流程顺畅,否则,未审批就可审核
})

# 先收款后发货订单自动核销
self.auto_reconcile_sell_order()
Expand Down

0 comments on commit 47b9547

Please sign in to comment.