Merge pull request #3318 from expsa/mu-awad-purchase-order-buttons-custom
[MOD] adding button restriction to purchase_requisition_custom
This commit is contained in:
commit
e8a2851fca
|
|
@ -3,6 +3,8 @@ from odoo.exceptions import UserError, ValidationError
|
|||
from odoo import api, fields, models, _
|
||||
from odoo.tools.float_utils import float_is_zero
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
|
|
@ -473,22 +475,30 @@ class PurchaseOrderCustom(models.Model):
|
|||
|
||||
def action_skip_budget(self):
|
||||
""" Skip purchase budget"""
|
||||
_logger.info("\n\n\n Skip Purchase Budget \n\n\n")
|
||||
for po_id in self:
|
||||
if po_id.state in ('wait_for_send', 'wait', 'sign') or po_id.request_id:
|
||||
# Deal with double validation process
|
||||
valid_amount = self.env.user.company_id.currency_id.compute(
|
||||
po_id.company_id.po_double_validation_amount, po_id.currency_id)
|
||||
# second_amount = self.env.user.company_id.currency_id.compute(po_id.company_id.second_approve, po_id.currency_id)
|
||||
_logger.info("\n\n\n Purchase state inside if 1 \n\n\n")
|
||||
|
||||
if po_id.company_id.po_double_validation == 'one_step' \
|
||||
or (po_id.company_id.po_double_validation == 'two_step' \
|
||||
and po_id.amount_total > valid_amount):
|
||||
_logger.info("\n\n\n Purchase state inside if 2 \n\n\n")
|
||||
po_id.write({'state': 'to approve'})
|
||||
else:
|
||||
_logger.info("\n\n\n Purchase state inside else1 \n\n\n")
|
||||
if po_id.email_to_vendor:
|
||||
_logger.info("\n\n\n Purchase state inside if 3 \n\n\n")
|
||||
po_id.write({'state': 'sent'})
|
||||
else:
|
||||
_logger.info("\n\n\n Purchase state inside else2 \n\n\n")
|
||||
po_id.write({'state': 'draft'})
|
||||
|
||||
_logger.info("\n\n\n Send to budet = false \n\n\n")
|
||||
po_id.write({'send_to_budget': False})
|
||||
|
||||
# @api.depends('name')
|
||||
|
|
|
|||
|
|
@ -315,6 +315,30 @@
|
|||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='button_confirm']" position="attributes">
|
||||
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
||||
<attribute name="states">draft</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='button_confirm'][1]" position="attributes">
|
||||
<attribute name="groups">purchase.group_purchase_manager</attribute>
|
||||
<attribute name="states">sent</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="/form/header/button[@name='action_rfq_send']" position="attributes">
|
||||
<attribute name="groups">purchase.group_purchase_manager, purchase.group_purchase_user</attribute>
|
||||
</xpath>
|
||||
<xpath expr="/form/header/button[@name='action_rfq_send'][1]" position="attributes">
|
||||
<attribute name="states">wait,draft,wait_for_send</attribute>
|
||||
<attribute name="groups">purchase.group_purchase_manager, purchase.group_purchase_user</attribute>
|
||||
</xpath>
|
||||
<xpath expr="/form/header/button[@name='action_rfq_send'][2]" position="attributes">
|
||||
<attribute name="groups">purchase.group_purchase_manager, purchase.group_purchase_user</attribute>
|
||||
</xpath>
|
||||
<!-- Update each print_quotation button -->
|
||||
<xpath expr="/form/header/button[@name='print_quotation']" position="attributes">
|
||||
<attribute name="groups">purchase.group_purchase_manager, purchase.group_purchase_user</attribute>
|
||||
<attribute name="states">draft,wait,wait_for_send</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<!-- Inherit the Purchase Requisition form and adding buttons to header tag -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue