1.采购去掉审核2.装夹预调工单验证优化
This commit is contained in:
@@ -151,23 +151,18 @@ class ProductTemplate(models.Model):
|
||||
class RePurchaseOrder(models.Model):
|
||||
_inherit = 'purchase.order'
|
||||
|
||||
check_status = fields.Selection([('pending', '待审核'), ('approved', '已审核'), ('fail', '不通过')], '审核状态')
|
||||
remark = fields.Text('备注')
|
||||
user_id = fields.Many2one(
|
||||
'res.users', string='买家', index=True, tracking=True,
|
||||
compute='_compute_user_id',
|
||||
store=True)
|
||||
|
||||
def button_confirming(self):
|
||||
self.write({'state': 'purchase', 'check_status': 'pending'})
|
||||
|
||||
@api.depends('partner_id')
|
||||
def _compute_user_id(self):
|
||||
if not self.user_id:
|
||||
if self.partner_id:
|
||||
self.user_id = self.partner_id.purchase_user_id.id
|
||||
self.check_status = 'pending'
|
||||
self.state = 'purchase'
|
||||
# self.state = 'purchase'
|
||||
else:
|
||||
self.user_id = self.env.user.id
|
||||
|
||||
@@ -190,28 +185,6 @@ class RePurchaseOrder(models.Model):
|
||||
if not line.taxes_id:
|
||||
raise UserError('请对【产品】中的【税】进行选择')
|
||||
|
||||
def write(self, vals):
|
||||
if self.env.user.has_group('sf_base.group_purchase_director'):
|
||||
if vals.get('check_status'):
|
||||
if vals['check_status'] in ('pending', False):
|
||||
vals['check_status'] = 'approved'
|
||||
return super().write(vals)
|
||||
|
||||
def button_confirm(self):
|
||||
for order in self:
|
||||
if order.state not in ['draft', 'sent', 'purchase']:
|
||||
continue
|
||||
order.order_line._validate_analytic_distribution()
|
||||
order._add_supplier_to_product()
|
||||
# Deal with double validation process
|
||||
if order._approval_allowed():
|
||||
order.button_approve()
|
||||
else:
|
||||
order.write({'state': 'to approve'})
|
||||
if order.partner_id not in order.message_partner_ids:
|
||||
order.message_subscribe([order.partner_id.id])
|
||||
return True
|
||||
|
||||
@api.onchange('order_line')
|
||||
def _onchange_order_line(self):
|
||||
for order in self:
|
||||
|
||||
@@ -8,28 +8,15 @@
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="replace">
|
||||
<field name="partner_id" widget="res_partner_many2one" context="{'is_supplier': True }"/>
|
||||
<field name="check_status" invisible="1"/>
|
||||
</field>
|
||||
<field name="currency_id" position="after">
|
||||
<field name="remark" attrs="{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}"/>
|
||||
<field name="remark" attrs="{'readonly': [('state', 'in', ['purchase'])]}"/>
|
||||
</field>
|
||||
<xpath expr="//form/header/button[@name='action_rfq_send'][1]" position="after">
|
||||
<button name="sf_sale.action_purchase_order_check_wizard" string="审核" type="action"
|
||||
context="{'default_order_id':active_id}" groups="sf_base.group_purchase_director"
|
||||
attrs="{'invisible': ['&',('check_status','in', ['approved','fail']),('state', 'in', ['purchase','draft'])]}"
|
||||
class="oe_highlight"/>
|
||||
|
||||
</xpath>
|
||||
<xpath expr="//form/header/button[@name='button_confirm'][2]" position="replace">
|
||||
<button name="button_confirm" type="object" context="{'validate_analytic': True}"
|
||||
string="确认订单" id="draft_confirm"
|
||||
groups="sf_base.group_purchase,sf_base.group_purchase_director"
|
||||
attrs="{'invisible': ['|','&','&', ('state', 'in', ['purchase','draft']), ('check_status', 'in', ['approved']), ('date_approve', '!=', False),'&', '&',('state', 'in', ['purchase', 'draft']),('check_status', 'in', [False, 'pending', 'fail']),('date_approve', '=', False)]}"
|
||||
/>
|
||||
<button name="button_confirming" type="object"
|
||||
string="确认订单" groups="sf_base.group_purchase,sf_base.group_purchase_director"
|
||||
attrs="{'invisible': ['&',('check_status','!=', False),('state', 'not in', ['draft','send'])]}"
|
||||
attrs="{'invisible': [('state', 'in', ['purchase'])]}"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath expr="//form/header/button[@name='action_rfq_send'][1]" position="replace">
|
||||
@@ -93,43 +80,35 @@
|
||||
<attribute name="groups">sf_base.group_purchase,sf_base.group_purchase_director</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</xpath>
|
||||
<field name="partner_ref" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</field>
|
||||
<field name="date_planned" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</field>
|
||||
<field name="receipt_reminder_email" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</field>
|
||||
<field name="user_id" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</field>
|
||||
<field name="origin" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</field>
|
||||
<field name="payment_term_id" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</field>
|
||||
<field name="fiscal_position_id" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</field>
|
||||
</field>
|
||||
@@ -153,13 +132,10 @@
|
||||
<field name="inherit_id" ref="purchase_stock.purchase_order_view_form_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="incoterm_id" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
</attribute>
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}</attribute>
|
||||
</field>
|
||||
<field name="incoterm_location" position="attributes">
|
||||
<attribute name="attrs">{'readonly': ['&',('state', 'in', ['purchase']),('check_status','in',
|
||||
['pending','approved'])]}
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['purchase'])]}
|
||||
</attribute>
|
||||
</field>
|
||||
</field>
|
||||
@@ -171,14 +147,8 @@
|
||||
<field name="inherit_id" ref="purchase.purchase_order_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<attribute name="default_order">check_status desc,date_approve asc</attribute>
|
||||
<attribute name="default_order">date_approve asc</attribute>
|
||||
</tree>
|
||||
<field name="amount_total" position="after">
|
||||
<field name="check_status" widget="badge"
|
||||
decoration-success="check_status == 'approved'"
|
||||
decoration-warning="check_status == 'pending'"
|
||||
decoration-danger="check_status == 'fail'"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user