[FIX] purchase_requisition_custom
This commit is contained in:
parent
cf96f72f60
commit
4a33952ce9
|
|
@ -37,7 +37,15 @@ class PurchaseOrderCustom(models.Model):
|
|||
|
||||
billed_amount = fields.Float(store=True, compute='_compute_amount')
|
||||
remaining_amount = fields.Float(store=True, compute='_compute_amount')
|
||||
has_requisition = fields.Boolean(compute="_compute_has_requisition", readonly=True)
|
||||
requisition_state = fields.Selection(related="requisition_id.state")
|
||||
|
||||
|
||||
@api.depends('requisition_id')
|
||||
def _compute_has_requisition(self):
|
||||
for record in self:
|
||||
record.has_requisition = bool(record.requisition_id)
|
||||
|
||||
def read(self, records):
|
||||
return super(PurchaseOrderCustom, self.sudo()).read(records)
|
||||
|
||||
|
|
@ -446,8 +454,8 @@ class PurchaseOrderCustom(models.Model):
|
|||
|
||||
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'})
|
||||
# if rec.requisition_id and rec.requisition_id.state != 'approve':
|
||||
# rec.requisition_id.write({'state': 'approve'})
|
||||
rec.write({'state': 'draft'})
|
||||
|
||||
@api.constrains('state')
|
||||
|
|
@ -465,7 +473,7 @@ class PurchaseOrderCustom(models.Model):
|
|||
def action_skip_budget(self):
|
||||
""" Skip purchase budget"""
|
||||
for po_id in self:
|
||||
if po_id.state in ('wait_for_send', 'wait') or po_id.request_id:
|
||||
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)
|
||||
|
|
@ -592,7 +600,8 @@ class PurchaseOrderCustom(models.Model):
|
|||
if self.amount_total == 0:
|
||||
raise ValidationError(_("Total Amount Can't be Zero"))
|
||||
self.write({'state': 'sign', 'is_signed': True})
|
||||
self.requisition_id.state = 'purchase_manager'
|
||||
if self.requisition_id.type_id.exclusive == 'exclusive':
|
||||
self.requisition_id.state = 'purchase_manager'
|
||||
|
||||
def button_confirm(self):
|
||||
for order in self:
|
||||
|
|
@ -618,8 +627,8 @@ class PurchaseOrderCustom(models.Model):
|
|||
budget_lines.write({'purchase_remain': amount})
|
||||
budget_lines.write({'reserve': abs(line.price_subtotal - budget_lines.reserve)})
|
||||
|
||||
if order.requisition_id.id:
|
||||
order.requisition_id.state = 'done'
|
||||
# if order.requisition_id.id:
|
||||
# order.requisition_id.state = 'done'
|
||||
if order.request_id:
|
||||
order.request_id.write({'state': 'done'})
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class PurchaseRequisitionCustom(models.Model):
|
|||
])
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('ongoing', 'Ongoing'),
|
||||
('in_progress', 'Confirmed'),
|
||||
('committee', 'Committee'),
|
||||
('purchase_manager', 'Purchase manager'),
|
||||
|
|
|
|||
|
|
@ -115,11 +115,11 @@
|
|||
icon="fa-file-text-o">
|
||||
<field name="attach_no" widget="statinfo" string="Documents"/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='payment_term_id']" position="after">
|
||||
<field invisible="1" readonly="1" name='res_model'/>
|
||||
<field invisible="1" readonly="1" name='res_id'/>
|
||||
</xpath>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='payment_term_id']" position="after">
|
||||
<field invisible="1" readonly="1" name='res_model'/>
|
||||
<field invisible="1" readonly="1" name='res_id'/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
|
||||
<button class="oe_stat_button" name="open_confirmation" type="object" string="Budget Confirmation"
|
||||
|
|
@ -134,6 +134,7 @@
|
|||
<xpath expr="/form/header/button[@name='action_rfq_send']" position="after">
|
||||
<field name="parent_state" invisible="1"/>
|
||||
<field name="already_voted" invisible="1"/>
|
||||
<field name="requisition_state" invisible="1"/>
|
||||
<button type="object" name="action_sign"
|
||||
groups="purchase_requisition_custom.group_sign_purchase_order"
|
||||
attrs="{'invisible':['|',('requisition_id','=',False),
|
||||
|
|
@ -160,8 +161,9 @@
|
|||
<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':['|',('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)]}"
|
||||
attrs="{'invisible': ['|', ('state', '!=', 'sign'), ('requisition_state', '!=', 'purchase_manager')]}"/>
|
||||
<button name="action_skip_budget" type="object" string="Skip Budget"
|
||||
attrs="{'invisible': ['|', ('state', '!=', 'sign'), ('requisition_state', '!=', 'purchase_manager')]}"
|
||||
groups="purchase_requisition_custom.group_skip_purchase_budget"/>
|
||||
<!-- <button name="button_draft" states="cancel" string="Set to Draft" type="object"/>-->
|
||||
</xpath>
|
||||
|
|
@ -349,7 +351,7 @@
|
|||
class="oe_highlight"/>
|
||||
<button type="object" groups="purchase_requisition_custom.group_quotation_purchase_requisition"
|
||||
name="action_quotation" string="Quotation"
|
||||
attrs="{'invisible':['&','|',('state','!=','accept'),('type','!=','project'),'|',('state','!=','in_progress'),('type','!=','operational')]}"
|
||||
attrs="{'invisible':['&','|',('state','!=','accept'),('type','!=','project'),'|',('state','not in',('in_progress', 'ongoing')),('type','!=','operational')]}"
|
||||
class="btn-primary"/>
|
||||
<button type="object" groups="purchase.group_purchase_user" name="action_budget"
|
||||
string="Send To Budget" states="purchase_manager" class="btn-primary"/>
|
||||
|
|
@ -393,20 +395,20 @@
|
|||
<xpath expr="//field[@name='user_id']" position="attributes">
|
||||
<attribute name="readonly">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='vendor_id']" position="attributes">
|
||||
<!-- <xpath expr="//field[@name='vendor_id']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
</xpath> -->
|
||||
<xpath expr="//field[@name='type_id']" position="replace">
|
||||
<field name="type_id" attrs="{
|
||||
'readonly': [('state','not in',('draft'))]}" required="1" widget="selection"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='line_ids']/tree[1]/field[@name='price_unit']" position="attributes">
|
||||
<!-- <xpath expr="//field[@name='line_ids']/tree[1]/field[@name='price_unit']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="/form/header/button[@name='action_cancel']" position="attributes">
|
||||
</xpath> -->
|
||||
<!-- <xpath expr="/form/header/button[@name='action_cancel']" position="attributes">
|
||||
<attribute name="attrs">{'invisible':[('state','in',('done','cancel'))]}</attribute>
|
||||
</xpath>
|
||||
</xpath> -->
|
||||
|
||||
<xpath expr="/form/header/button[@name='action_in_progress']" position="replace">
|
||||
<button name="action_in_progress"
|
||||
|
|
@ -415,7 +417,7 @@
|
|||
</xpath>
|
||||
<xpath expr="/form/header/button[@name='action_cancel']" position="replace">
|
||||
<button name="action_cancel" groups="purchase_requisition_custom.group_cancel_purchase_requisition"
|
||||
states="draft,in_progress" string="Cancel" type="object"/>
|
||||
states="draft,in_progress,ongoing" string="Cancel" type="object"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/header/button[@name='action_draft']" position="attributes">
|
||||
<attribute name="attrs">{'invisible':[('state','!=','cancel')]}</attribute>
|
||||
|
|
@ -427,7 +429,7 @@
|
|||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="/form/header/field[@name='state']" position="replace">
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,in_progress,done"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,in_progress,done" attrs="{'invisible': [('is_quantity_copy', '=', 'none')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='date_end']" position="before">
|
||||
<!-- <field name="agreement_name" attrs="{'readonly': [('state','!=', 'draft')]}"/>-->
|
||||
|
|
|
|||
Loading…
Reference in New Issue