采购验收、证明
This commit is contained in:
@@ -24,6 +24,13 @@ class StockPicking(models.Model):
|
||||
department_id = fields.Many2one('hr.department', string="部门")
|
||||
certifier_id = fields.Many2one('res.users', string="证明人")
|
||||
user_id = fields.Many2one('res.users', string="采购人员", compute="_compute_origin")
|
||||
receipt_status = fields.Selection([
|
||||
('receipt', '入库'),
|
||||
('acceptance', '验收'),
|
||||
('certification', '证明')
|
||||
], string="入库单状态", default='receipt')
|
||||
acceptance_date = fields.Datetime(string="验收时间", readonly=True)
|
||||
certification_date = fields.Datetime(string="证明时间", readonly=True)
|
||||
json_display = fields.Char(
|
||||
string="物品详情",
|
||||
compute='_compute_json_display',
|
||||
@@ -34,8 +41,12 @@ class StockPicking(models.Model):
|
||||
def _onchange_user_id(self):
|
||||
if self.user_id:
|
||||
self.department_id = self.user_id.employee_ids.department_id.id
|
||||
# 设置验收人为采购人员对应的员工
|
||||
if self.user_id.employee_ids:
|
||||
self.employee_id = self.user_id.employee_ids[0].id
|
||||
else:
|
||||
self.department_id = False
|
||||
self.employee_id = False
|
||||
|
||||
@api.constrains("department_id")
|
||||
def _check_department_id(self):
|
||||
@@ -87,6 +98,14 @@ class StockPicking(models.Model):
|
||||
record.user_id = False
|
||||
|
||||
def button_validate(self):
|
||||
"""重写确认入库方法,在证明状态时更新证明人和时间"""
|
||||
for record in self:
|
||||
if record.receipt_status == 'certification':
|
||||
# 使用write方法强制写入只读字段
|
||||
record.write({
|
||||
'certifier_id': self.env.user.id,
|
||||
'certification_date': fields.Datetime.now()
|
||||
})
|
||||
self.employee_id = self.env.user.employee_ids.id
|
||||
return super(StockPicking, self).button_validate()
|
||||
|
||||
@@ -94,4 +113,11 @@ class StockPicking(models.Model):
|
||||
"""手动刷新json_display字段"""
|
||||
for record in self:
|
||||
record._compute_json_display()
|
||||
return True
|
||||
|
||||
def action_acceptance(self):
|
||||
"""验收按钮"""
|
||||
self.ensure_one()
|
||||
self.acceptance_date = fields.Datetime.now()
|
||||
self.receipt_status = 'acceptance'
|
||||
return True
|
||||
@@ -6,17 +6,29 @@
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='picking_type_id']" position="after">
|
||||
<field name="department_id"/>
|
||||
<field name="department_id" options="{'no_create': True}"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='operations']//field[@name='move_ids_without_package']" position="after">
|
||||
<xpath expr="//field[@name='origin']" position="after">
|
||||
<field name="receipt_status"/>
|
||||
<field name="user_id" string="采购人员"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='operations']//field[@name='move_ids_without_package']//field[@name='product_id']" position="attributes">
|
||||
<attribute name="options">{'no_create': True}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header/button[@name='%(stock.act_stock_return_picking)d']" position="after">
|
||||
<button name="action_acceptance" string="验收" type="object" class="btn-primary" invisible="receipt_status != 'receipt'"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='operations']/field[@name='move_ids_without_package']" position="after">
|
||||
<group>
|
||||
<group>
|
||||
<field name="employee_id" string="验收人" required="1"/>
|
||||
<field name="employee_id" string="验收人" required="1" options="{'no_create': True}"/>
|
||||
<field name="document_ids" widget="preview_many2many" required="1"/>
|
||||
<field name="acceptance_date"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="certifier_id"/>
|
||||
<field name="certifier_id" options="{'no_create': True}"/>
|
||||
<field name="certifier_document_ids" widget="preview_many2many" required="1"/>
|
||||
<field name="certification_date"/>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user