fix
This commit is contained in:
parent
1034e829b8
commit
48f4dc9d6b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -279,23 +279,34 @@ class PurchaseOrderCustom(models.Model):
|
|||
def button_approve(self):
|
||||
for rec in self:
|
||||
if rec.requisition_id and rec.requisition_id.state != 'approve':
|
||||
rec.requisition_id.write({'state':'approve'})
|
||||
rec.write({'state': 'draft'})
|
||||
raise ValidationError(_("Purchase agreement not approved"))
|
||||
else:
|
||||
# You can Approve
|
||||
for line in self.order_line:
|
||||
analytic_account_id = line.account_analytic_id
|
||||
budget_post = self.env['account.budget.post'].search([]).filtered(
|
||||
lambda
|
||||
x: line.product_id.property_account_expense_id.id and line.product_id.property_account_expense_id.id or line.product_id.categ_id.property_account_expense_categ_id.id in x.account_ids.ids)
|
||||
budget_lines = analytic_account_id.crossovered_budget_line.filtered(
|
||||
lambda x: x.general_budget_id in budget_post and
|
||||
x.crossovered_budget_id.state == 'done' and
|
||||
fields.Date.from_string(x.date_from) <= fields.Date.from_string(
|
||||
rec.date_order) <= fields.Date.from_string(x.date_to))
|
||||
super(PurchaseOrderCustom, rec).button_approve()
|
||||
|
||||
# raise ValidationError(_("Purchase agreement not approved"))
|
||||
# else:
|
||||
# # You can Approve
|
||||
# for line in self.order_line:
|
||||
# analytic_account_id = line.account_analytic_id
|
||||
# budget_post = self.env['account.budget.post'].search([]).filtered(
|
||||
# lambda
|
||||
# x: line.product_id.property_account_expense_id.id and line.product_id.property_account_expense_id.id or line.product_id.categ_id.property_account_expense_categ_id.id in x.account_ids.ids)
|
||||
# budget_lines = analytic_account_id.crossovered_budget_line.filtered(
|
||||
# lambda x: x.general_budget_id in budget_post and
|
||||
# x.crossovered_budget_id.state == 'done' and
|
||||
# fields.Date.from_string(x.date_from) <= fields.Date.from_string(
|
||||
# rec.date_order) <= fields.Date.from_string(x.date_to))
|
||||
# super(PurchaseOrderCustom, rec).button_approve()
|
||||
def action_rfq_send(self):
|
||||
res=super(PurchaseOrderCustom,self).action_rfq_send()
|
||||
if self.state=='wait':
|
||||
self.state='sent'
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def action_approve_po(self):
|
||||
for rec in self:
|
||||
if rec.requisition_id and rec.requisition_id.state != 'approve':
|
||||
rec.requisition_id.write({'state': 'approve'})
|
||||
rec.write({'state': 'draft'})
|
||||
|
||||
@api.constrains('state')
|
||||
def _state_on_change(self):
|
||||
|
|
@ -308,10 +319,6 @@ class PurchaseOrderCustom(models.Model):
|
|||
for rec in self:
|
||||
if rec.requisition_id.project_id:
|
||||
rec.project_id = rec.requisition_id.project_id.id
|
||||
def action_rfq_send(self):
|
||||
res = super(PurchaseOrderCustom, self).action_rfq_send()
|
||||
self.write({'state':'sent'})
|
||||
return res
|
||||
|
||||
def action_skip_budget(self):
|
||||
""" Skip purchase budget"""
|
||||
|
|
@ -465,6 +472,7 @@ class PurchaseOrderCustom(models.Model):
|
|||
self.request_id.write({'state': 'done'})
|
||||
return res
|
||||
|
||||
|
||||
def action_unsign(self):
|
||||
"""
|
||||
Move document to Wait state
|
||||
|
|
|
|||
|
|
@ -233,33 +233,31 @@ class PurchaseRequisitionCustom(models.Model):
|
|||
raise ValidationError(_("Please add Committe Members"))
|
||||
|
||||
def action_approve(self):
|
||||
self.write({'state': 'approve'})
|
||||
purchase_orders = self.env['purchase.order'].search([('requisition_id', '=', self.id)])
|
||||
po_order_approval = self.env.company.po_double_validation == 'two_step'
|
||||
for po_id in purchase_orders:
|
||||
# Deal with double validation process for first approve
|
||||
valid_amount = self.env.user.company_id.currency_id.compute(po_id.company_id.po_double_validation_amount,
|
||||
po_id.currency_id)
|
||||
if po_order_approval:
|
||||
|
||||
# purchase_orders = self.env['purchase.order'].search([('requisition_id', '=', self.id)])
|
||||
# po_order_approval = self.env.company.po_double_validation == 'two_step'
|
||||
# for po_id in purchase_orders:
|
||||
# # Deal with double validation process for first approve
|
||||
# valid_amount = self.env.user.company_id.currency_id.compute(po_id.company_id.po_double_validation_amount,
|
||||
# po_id.currency_id)
|
||||
# if po_order_approval:
|
||||
#
|
||||
# if po_id.amount_total > valid_amount:
|
||||
# po_id.write({'state': 'to approve'})
|
||||
# self.write({'state': 'second_approve'})
|
||||
# else:
|
||||
# if po_id.email_to_vendor:
|
||||
# po_id.write({'state': 'sent'})
|
||||
# else:
|
||||
# po_id.write({'state': 'draft'})
|
||||
# po_id.write({'send_to_budget': False})
|
||||
# self.write({'state': 'approve'})
|
||||
# else:
|
||||
# if po_id.email_to_vendor:
|
||||
# po_id.write({'state': 'sent'})
|
||||
# else:
|
||||
# po_id.write({'state': 'draft'})
|
||||
# po_id.write({'send_to_budget': False})
|
||||
# self.write({'state': 'approve'})
|
||||
if po_id.amount_total > valid_amount:
|
||||
po_id.write({'state': 'to approve'})
|
||||
self.write({'state': 'second_approve'})
|
||||
else:
|
||||
# if po_id.email_to_vendor:
|
||||
# po_id.write({'state': 'sent'})
|
||||
# else:
|
||||
po_id.write({'state': 'draft'})
|
||||
po_id.write({'send_to_budget': False})
|
||||
self.write({'state': 'approve'})
|
||||
else:
|
||||
# if po_id.email_to_vendor:
|
||||
# po_id.write({'state': 'sent'})
|
||||
# else:
|
||||
po_id.write({'state': 'draft'})
|
||||
po_id.write({'send_to_budget': False})
|
||||
self.write({'state': 'approve'})
|
||||
|
||||
def second_approval(self):
|
||||
purchase_orders = self.env['purchase.order'].search([('requisition_id', '=', self.id)])
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@
|
|||
'|', ('state','in',['sign','purchase','to approve','done',
|
||||
'cancel','budget_rejected','wait_for_send','waiting']), ('is_signed', '=', True)]}"
|
||||
string="Sign"/>
|
||||
<button type="object" name="action_approve_po" string="Confirm" class="oe_highlight"
|
||||
attrs="{'invisible':['|',('requisition_id','=',False),'|',('state','not in',('to approve')),('is_purchase_budget','=',False)]}"/>
|
||||
<button type="object" name="action_select" groups="purchase_requisition_custom.committe_member"
|
||||
attrs="{'invisible':[('state','in',['wait','draft','done','purchase','wait_for_send','sent','waiting','cancel'])]}"
|
||||
string="Select"/>
|
||||
|
|
@ -134,7 +136,7 @@
|
|||
|
||||
<button string='PO To Contract' name="open_convert_po_contract" type="object"
|
||||
class="oe_highlight" groups="purchase.group_purchase_manager"
|
||||
attrs="{'invisible':[('state','in',('draft','wait','wait_for_send','sent','sign','waiting','purchase','cancel'))]}"/>
|
||||
attrs="{'invisible':[('state','in',('draft','wait','wait_for_send','sent','to approve','sign','waiting','purchase','cancel'))]}"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='date_order']" position="after">
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue