[Update]Purchase order cycle
This commit is contained in:
parent
9e81fc2491
commit
2b00678975
|
|
@ -6,4 +6,4 @@ from . import budget_confirmation
|
||||||
from . import purchase_requisition_custom
|
from . import purchase_requisition_custom
|
||||||
from . import purchase_order
|
from . import purchase_order
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
from . import res_settings
|
from . import res_settings,mail_compose_message
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
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')),
|
||||||
|
]).write({'state': 'sent'})
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
@ -31,7 +31,7 @@ class PurchaseOrderCustom(models.Model):
|
||||||
('done', 'Locked'),
|
('done', 'Locked'),
|
||||||
('cancel', 'Cancelled'),
|
('cancel', 'Cancelled'),
|
||||||
('budget_rejected', 'Rejected By Budget'),
|
('budget_rejected', 'Rejected By Budget'),
|
||||||
('wait_for_send', 'Waiting For Send to Budget')])
|
('wait_for_send', 'Waiting For Send to Budget')],default='wait')
|
||||||
department_id = fields.Many2one('hr.department')
|
department_id = fields.Many2one('hr.department')
|
||||||
purpose = fields.Char()
|
purpose = fields.Char()
|
||||||
category_ids = fields.Many2many('product.category', string='Categories')
|
category_ids = fields.Many2many('product.category', string='Categories')
|
||||||
|
|
@ -254,6 +254,17 @@ class PurchaseOrderCustom(models.Model):
|
||||||
else:
|
else:
|
||||||
rec.is_purchase_budget = False
|
rec.is_purchase_budget = False
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def default_get(self, fields):
|
||||||
|
res = super(PurchaseOrderCustom, self).default_get(fields)
|
||||||
|
purchase_budget = self.env.company.purchase_budget
|
||||||
|
if purchase_budget:
|
||||||
|
res['is_purchase_budget'] = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
res['is_purchase_budget'] = False
|
||||||
|
return res
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
requisition_id = vals.get('requisition_id', False)
|
requisition_id = vals.get('requisition_id', False)
|
||||||
|
|
@ -263,10 +274,6 @@ class PurchaseOrderCustom(models.Model):
|
||||||
|
|
||||||
if requisition_id:
|
if requisition_id:
|
||||||
vals['send_to_budget'] = True
|
vals['send_to_budget'] = True
|
||||||
else:
|
|
||||||
if self.env.company.purchase_budget:
|
|
||||||
vals['state'] = 'wait_for_send'
|
|
||||||
|
|
||||||
return super(PurchaseOrderCustom, self).create(vals)
|
return super(PurchaseOrderCustom, self).create(vals)
|
||||||
|
|
||||||
def button_approve(self):
|
def button_approve(self):
|
||||||
|
|
|
||||||
|
|
@ -113,9 +113,10 @@
|
||||||
'cancel','budget_rejected','wait_for_send','waiting']), ('is_signed', '=', True)]}"
|
'cancel','budget_rejected','wait_for_send','waiting']), ('is_signed', '=', True)]}"
|
||||||
string="Sign"/>
|
string="Sign"/>
|
||||||
<button type="object" name="action_select" groups="purchase_requisition_custom.committe_member"
|
<button type="object" name="action_select" groups="purchase_requisition_custom.committe_member"
|
||||||
attrs="{'invisible':[('state','in',['done','purchase'])]}" string="Select"/>
|
attrs="{'invisible':[('state','in',['wait','draft','done','purchase','wait_for_send','sent','waiting','cancel'])]}"
|
||||||
|
string="Select"/>
|
||||||
<button type="object" name="action_refuse" groups="purchase_requisition_custom.committe_member"
|
<button type="object" name="action_refuse" groups="purchase_requisition_custom.committe_member"
|
||||||
attrs="{'invisible':[('state','in',['done','purchase'])]}"
|
attrs="{'invisible':[('state','in',['wait','draft','done','purchase','wait_for_send','sent','waiting','cancel'])]}"
|
||||||
string="Refuse"/>
|
string="Refuse"/>
|
||||||
<button type="object" name="action_unsign"
|
<button type="object" name="action_unsign"
|
||||||
groups="purchase_requisition_custom.group_unsign_purchase_order" string="UnSign"
|
groups="purchase_requisition_custom.group_unsign_purchase_order" string="UnSign"
|
||||||
|
|
@ -123,16 +124,17 @@
|
||||||
<button type="object" name="budget_resend" string="Resend To Budget Check" class="oe_highlight"
|
<button type="object" name="budget_resend" string="Resend To Budget Check" class="oe_highlight"
|
||||||
states="budget_rejected"/>
|
states="budget_rejected"/>
|
||||||
<button type="object" name="action_budget" string="Send To Budget Check" class="oe_highlight"
|
<button type="object" name="action_budget" string="Send To Budget Check" class="oe_highlight"
|
||||||
states="wait_for_send"/>
|
attrs="{'invisible':[('is_purchase_budget','=',False)]}"/>
|
||||||
<button name="action_skip_budget" type="object" string="Skip Budget" states="wait_for_send"
|
<button name="action_skip_budget" type="object" string="Skip Budget" attrs="{'invisible':[('is_purchase_budget','=',False)]}"
|
||||||
groups="purchase_requisition_custom.group_skip_purchase_budget"/>
|
groups="purchase_requisition_custom.group_skip_purchase_budget"/>
|
||||||
<button name="button_draft" states="wait_for_send" string="Set to Draft" type="object"/>
|
<!-- <button name="button_draft" states="cancel" string="Set to Draft" type="object"/>-->
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//button[@name='button_draft']" position="after">
|
<xpath expr="//button[@name='button_draft']" position="after">
|
||||||
<!-- attrs="{'invisible':[('state','=','draft')]}"-->
|
|
||||||
<button string='PO To Contract' name="open_convert_po_contract" type="object"
|
<button string='PO To Contract' name="open_convert_po_contract" type="object"
|
||||||
class="oe_highlight" groups="purchase.group_purchase_manager" />
|
class="oe_highlight" groups="purchase.group_purchase_manager"
|
||||||
|
attrs="{'invisible':[('state','in',('draft','wait','wait_for_send','sent','waiting','purchase','cancel'))]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//field[@name='date_order']" position="after">
|
<xpath expr="//field[@name='date_order']" position="after">
|
||||||
|
|
@ -142,15 +144,27 @@
|
||||||
|
|
||||||
<xpath expr="/form/header/button[@id='draft_confirm']" position="attributes">
|
<xpath expr="/form/header/button[@id='draft_confirm']" position="attributes">
|
||||||
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
||||||
<!-- <attribute name="states">""</attribute>-->
|
<attribute name="states">""</attribute>
|
||||||
<!-- <attribute name="attrs">{'invisible':[('state','=','draft')]}</attribute>-->
|
<attribute name="attrs">
|
||||||
|
{'invisible':[('state','in',('wait','wait_for_send','sent','waiting','purchase','cancel'))]}
|
||||||
|
</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="/form/header/button[@id='bid_confirm']" position="attributes">
|
||||||
|
<attribute name="states">""</attribute>
|
||||||
|
<attribute name="attrs">
|
||||||
|
{'invisible':['|',('state','in',('draft','wait_for_send','waiting','purchase','cancel')),('is_purchase_budget','=',True)]}
|
||||||
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="/form/header/button[@name='action_rfq_send']" position="attributes">
|
<xpath expr="/form/header/button[@name='action_rfq_send']" position="attributes">
|
||||||
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="/form/header/button[@name='action_rfq_send'][1]" position="attributes">
|
||||||
|
<attribute name="states">wait,draft,wait_for_send</attribute>
|
||||||
|
</xpath>
|
||||||
<xpath expr="/form/header/button[@name='print_quotation']" position="attributes">
|
<xpath expr="/form/header/button[@name='print_quotation']" position="attributes">
|
||||||
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
||||||
|
<attribute name="states">draft,wait,wait_for_send</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/header/button[@name='button_cancel']" position="attributes">
|
<xpath expr="/form/header/button[@name='button_cancel']" position="attributes">
|
||||||
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
||||||
|
|
@ -158,7 +172,7 @@
|
||||||
|
|
||||||
|
|
||||||
<xpath expr="/form/header/button[@name='button_cancel']" position="attributes">
|
<xpath expr="/form/header/button[@name='button_cancel']" position="attributes">
|
||||||
<attribute name="states">draft,to approve,sent,purchase,wait_for_send</attribute>
|
<attribute name="states">draft,wait,to approve,sent,purchase,wait_for_send</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="/form/sheet/group/group[2]/field[@name='date_order']" position="after">
|
<xpath expr="/form/sheet/group/group[2]/field[@name='date_order']" position="after">
|
||||||
<field name="select" invisible="1"/>
|
<field name="select" invisible="1"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue