[REF] purchase_requisition: new stages workflow for blanket orders
The stages workflow of purchase tender is not suitable for blanket order. the steps bid selection is use only with purchase tender. Now : PT : draft -> confirmed -> bid selection -> closed BO : draft -> ongoing -> closed
This commit is contained in:
committed by
Pierre Masereel
parent
87af05ae76
commit
b3ac2d2f48
@@ -6,6 +6,16 @@ from odoo.addons import decimal_precision as dp
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
PURCHASE_REQUISITION_STATES = [
|
||||
('draft', 'Draft'),
|
||||
('ongoing', 'Ongoing'),
|
||||
('in_progress', 'Confirmed'),
|
||||
('open', 'Bid Selection'),
|
||||
('done', 'Closed'),
|
||||
('cancel', 'Cancelled')
|
||||
]
|
||||
|
||||
|
||||
class PurchaseRequisitionType(models.Model):
|
||||
_name = "purchase.requisition.type"
|
||||
_description = "Purchase Agreement Type"
|
||||
@@ -59,15 +69,18 @@ class PurchaseRequisition(models.Model):
|
||||
purchase_ids = fields.One2many('purchase.order', 'requisition_id', string='Purchase Orders', states={'done': [('readonly', True)]})
|
||||
line_ids = fields.One2many('purchase.requisition.line', 'requisition_id', string='Products to Purchase', states={'done': [('readonly', True)]}, copy=True)
|
||||
warehouse_id = fields.Many2one('stock.warehouse', string='Warehouse')
|
||||
state = fields.Selection([('draft', 'Draft'), ('in_progress', 'Confirmed'),
|
||||
('open', 'Bid Selection'), ('done', 'Done'),
|
||||
('cancel', 'Cancelled')],
|
||||
state = fields.Selection(PURCHASE_REQUISITION_STATES,
|
||||
'Status', track_visibility='onchange', required=True,
|
||||
copy=False, default='draft')
|
||||
state_blanket_order = fields.Selection(PURCHASE_REQUISITION_STATES, compute='_set_state')
|
||||
account_analytic_id = fields.Many2one('account.analytic.account', 'Analytic Account')
|
||||
picking_type_id = fields.Many2one('stock.picking.type', 'Operation Type', required=True, default=_get_picking_in)
|
||||
is_quantity_copy = fields.Selection(related='type_id.quantity_copy', readonly=True)
|
||||
|
||||
@api.depends('state')
|
||||
def _set_state(self):
|
||||
self.state_blanket_order = self.state
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
rec = super(PurchaseRequisition, self).create(vals)
|
||||
@@ -123,7 +136,9 @@ class PurchaseRequisition(models.Model):
|
||||
if requisition_line.product_qty <= 0.0:
|
||||
raise UserError(_('You cannot confirm the blanket order without quantity.'))
|
||||
requisition_line.create_supplier_info()
|
||||
self.write({'state': 'in_progress'})
|
||||
self.write({'state': 'ongoing'})
|
||||
else:
|
||||
self.write({'state': 'in_progress'})
|
||||
|
||||
@api.multi
|
||||
def action_open(self):
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_ref" position="after">
|
||||
<field name="requisition_id"
|
||||
domain="[('state', 'in', ('in_progress', 'open')), ('vendor_id', 'in', (partner_id, False))]"/>
|
||||
domain="[('state', 'in', ('in_progress', 'open', 'ongoing')), ('vendor_id', 'in', (partner_id, False))]"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -139,13 +139,14 @@
|
||||
attrs="{'invisible': [('state', '!=', 'open')]}"/>
|
||||
<button name="%(action_purchase_requisition_to_so)d" type="action"
|
||||
string="New Quotation" class="btn-primary"
|
||||
attrs="{'invisible': [('state', '!=', 'in_progress')]}"/>
|
||||
attrs="{'invisible': [('state', 'not in', ('in_progress', 'ongoing'))]}"/>
|
||||
<button name="action_in_progress" states="draft" string="Confirm" type="object" class="btn-primary"/>
|
||||
<button name="action_open" states="in_progress" string="Validate" type="object" class="btn-primary"/>
|
||||
<button name="action_done" states="open" string="Done" type="object" class="btn-primary"/>
|
||||
<button name="action_done" states="open,ongoing" string="Close" type="object" class="btn-primary"/>
|
||||
<button name="action_draft" states="cancel" string="Reset to Draft" type="object"/>
|
||||
<button name="action_cancel" states="draft,in_progress" string="Cancel Call" type="object"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,in_progress,open,done"/>
|
||||
<button name="action_cancel" states="draft,in_progress,ongoing" string="Cancel" type="object"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,in_progress,open,done" attrs="{'invisible': [('is_quantity_copy', '=', 'none')]}"/>
|
||||
<field name="state_blanket_order" widget="statusbar" statusbar_visible="draft,ongoing,done" attrs="{'invisible': [('is_quantity_copy', '!=', 'none')]}"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
@@ -165,13 +166,13 @@
|
||||
<field name="is_quantity_copy" invisible='1'/>
|
||||
<field name="user_id" attrs="{'readonly': [('state','not in',('draft','in_progress','open'))]}"/>
|
||||
<field name="type_id" attrs="{'readonly': [('state','!=','draft')]}" widget="selection"/>
|
||||
<field name="vendor_id" context="{'search_default_supplier':1, 'default_supplier':1, 'default_customer':0}" domain="[('supplier','=',True)]" attrs="{'required': [('is_quantity_copy', '=', 'none')]}"/>
|
||||
<field name="vendor_id" context="{'search_default_supplier':1, 'default_supplier':1, 'default_customer':0}" domain="[('supplier','=',True)]" attrs="{'required': [('is_quantity_copy', '=', 'none')], 'readonly': [('state', 'in', ['ongoing','done'])]}"/>
|
||||
<field name="account_analytic_id" colspan="2" groups="analytic.group_analytic_accounting" attrs="{'readonly': [('state','not in',('draft'))]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="date_end" attrs="{'readonly': [('state','not in',('draft','in_progress','open'))]}"/>
|
||||
<field name="ordering_date" attrs="{'readonly': [('state','not in',('draft','in_progress','open'))]}"/>
|
||||
<field name="schedule_date" attrs="{'readonly': [('state','not in',('draft','in_progress','open'))]}"/>
|
||||
<field name="date_end" attrs="{'readonly': [('state','not in',('draft','in_progress','open','ongoing'))]}"/>
|
||||
<field name="ordering_date" attrs="{'readonly': [('state','not in',('draft','in_progress','open','ongoing'))]}"/>
|
||||
<field name="schedule_date" attrs="{'readonly': [('state','not in',('draft','in_progress','open','ongoing'))]}"/>
|
||||
<field name="origin" placeholder="e.g. PO0025" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||
<field name="picking_type_id" widget="selection" groups="stock.group_adv_location" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" attrs="{'readonly': [('state','not in',('draft'))]}"/>
|
||||
@@ -209,7 +210,7 @@
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user