fix
This commit is contained in:
parent
0774480668
commit
ce6dfb1e8e
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.
|
|
@ -4,16 +4,16 @@ from odoo import _, api, fields, models, tools
|
|||
class MailComposer(models.TransientModel):
|
||||
_inherit = 'mail.compose.message'
|
||||
|
||||
def send_mail(self, auto_commit=False):
|
||||
res = super(MailComposer, self).send_mail(auto_commit=auto_commit)
|
||||
context = self._context
|
||||
if self.model == 'purchase.order':
|
||||
x = self.env['purchase.order'].search([
|
||||
('id', 'in', context.get('active_ids')),
|
||||
])
|
||||
print(x.is_purchase_budget, 'is_purchase_budget')
|
||||
self.env['purchase.order'].search([
|
||||
('id', 'in', context.get('active_ids')),('state','not in',["purchase"]),
|
||||
]).write({'state': 'sent'})
|
||||
|
||||
return res
|
||||
# def send_mail(self, auto_commit=False):
|
||||
# res = super(MailComposer, self).send_mail(auto_commit=auto_commit)
|
||||
# context = self._context
|
||||
# if self.model == 'purchase.order':
|
||||
# x = self.env['purchase.order'].search([
|
||||
# ('id', 'in', context.get('active_ids')),
|
||||
# ])
|
||||
# print(x.is_purchase_budget, 'is_purchase_budget')
|
||||
# self.env['purchase.order'].search([
|
||||
# ('id', 'in', context.get('active_ids')),('state','not in',["purchase"]),
|
||||
# ]).write({'state': 'sent'})
|
||||
#
|
||||
# return res
|
||||
|
|
|
|||
|
|
@ -279,20 +279,23 @@ class PurchaseOrderCustom(models.Model):
|
|||
def button_approve(self):
|
||||
for rec in self:
|
||||
if rec.requisition_id and rec.requisition_id.state != '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()
|
||||
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()
|
||||
|
||||
@api.constrains('state')
|
||||
def _state_on_change(self):
|
||||
|
|
@ -305,6 +308,10 @@ 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"""
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ class PurchaseRequisitionCustom(models.Model):
|
|||
"default_department_name": self.department_id.id,
|
||||
"default_category_ids": self.category_ids.ids,
|
||||
"default_purpose": self.purpose,
|
||||
"default_state": 'draft',
|
||||
"default_state": 'wait',
|
||||
"default_send_to_budget": True,
|
||||
"default_request_id": self.request_id.id if self.request_id else False},
|
||||
}
|
||||
|
|
@ -233,31 +233,33 @@ class PurchaseRequisitionCustom(models.Model):
|
|||
raise ValidationError(_("Please add Committe Members"))
|
||||
|
||||
def action_approve(self):
|
||||
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:
|
||||
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'})
|
||||
# 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'})
|
||||
|
||||
def second_approval(self):
|
||||
purchase_orders = self.env['purchase.order'].search([('requisition_id', '=', self.id)])
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@
|
|||
<button type="object" name="budget_resend" string="Resend To Budget Check" class="oe_highlight"
|
||||
states="budget_rejected"/>
|
||||
<button type="object" name="action_budget" string="Send To Budget Check" class="oe_highlight"
|
||||
attrs="{'invisible':['|',('is_purchase_budget','=',False),('state','not in',('wait','sent'))]}"/>
|
||||
<button name="action_skip_budget" type="object" string="Skip Budget" attrs="{'invisible':['|',('is_purchase_budget','=',False),('state','not in',('wait','sent'))]}"
|
||||
attrs="{'invisible':['|',('requisition_id','!=',False),'|',('state','not in',('wait','sent')),('is_purchase_budget','=',False)]}"/>
|
||||
<button name="action_skip_budget" type="object" string="Skip Budget" attrs="{'invisible':['|',('requisition_id','!=',False),'|',('state','not in',('wait','sent')),('is_purchase_budget','=',False)]}"
|
||||
groups="purchase_requisition_custom.group_skip_purchase_budget"/>
|
||||
<!-- <button name="button_draft" states="cancel" string="Set to Draft" type="object"/>-->
|
||||
</xpath>
|
||||
|
|
@ -146,7 +146,7 @@
|
|||
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
||||
<attribute name="states">""</attribute>
|
||||
<attribute name="attrs">
|
||||
{'invisible':[('state','in',('wait','wait_for_send','sign','sent','waiting','purchase','cancel'))]}
|
||||
{'invisible':[('state','in',('wait','wait_for_send','sign','sent','to approve','waiting','purchase','cancel'))]}
|
||||
</attribute>
|
||||
</xpath>
|
||||
<xpath expr="/form/header/button[@id='bid_confirm']" position="attributes">
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue