diff --git a/yuthon_purchase/models/purchase_workflow.py b/yuthon_purchase/models/purchase_workflow.py index fd9f9a507..a75507a7a 100644 --- a/yuthon_purchase/models/purchase_workflow.py +++ b/yuthon_purchase/models/purchase_workflow.py @@ -28,6 +28,7 @@ class PurchaseWorkflow(models.Model): document_ids = fields.Many2many('ir.attachment', string="附件") active = fields.Boolean('启用', default=True, tracking=True) work_end = fields.Boolean(string="审批结束", default=False, tracking=True) + purchase_order_id = fields.Many2one('purchase.order', string="采购订单", readonly=True) purchase_type = fields.Selection([('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务')], string="采购类型", required=True, default='fixed') @@ -65,6 +66,7 @@ class PurchaseWorkflow(models.Model): 'company_id': rec.company_id.id, 'user_id': rec.user_id.id, }) + rec.purchase_order_id = purchase_order.id order_lines = [] if rec.purchase_type == 'fixed': for line in rec.fixed_line_ids: diff --git a/yuthon_purchase/views/purchase_workflow_views.xml b/yuthon_purchase/views/purchase_workflow_views.xml index d632c22c2..f7b3b9aec 100644 --- a/yuthon_purchase/views/purchase_workflow_views.xml +++ b/yuthon_purchase/views/purchase_workflow_views.xml @@ -57,6 +57,7 @@ + diff --git a/yuthon_stock/models/inherit_stock_picking.py b/yuthon_stock/models/inherit_stock_picking.py index 22bcc9afd..6eeebb2cf 100644 --- a/yuthon_stock/models/inherit_stock_picking.py +++ b/yuthon_stock/models/inherit_stock_picking.py @@ -17,13 +17,29 @@ class StockPicking(models.Model): store=True ) - @api.onchange('employee_id') - def _onchange_employee_id(self): - if self.employee_id: - self.department_id = self.employee_id.department_id.id + @api.onchange('user_id') + def _onchange_user_id(self): + if self.user_id: + self.department_id = self.user_id.employee_ids.department_id.id else: self.department_id = False + @api.constrains("department_id") + def _check_department_id(self): + if self.department_id: + location_dest_id = self.env['stock.location'].search([('name', '=', self.department_id.name)], limit=1) + if not location_dest_id: + company_id = self.user_id.company_id + location_id = self.env['stock.location'].search([('complete_name', '=', company_id.name)]) + location_dest_id = self.env['stock.location'].create({ + 'name': self.department_id.name, + 'location_id': location_id.id, + 'complete_name': company_id.name, + 'usage': 'internal', + 'company_id': company_id.id, + }) + self.location_dest_id = location_dest_id + @api.depends( 'move_ids_without_package.product_id', 'move_ids_without_package.product_uom_qty', diff --git a/yuthon_stock/views/inherit_stock_picking.xml b/yuthon_stock/views/inherit_stock_picking.xml index 9e55b0f0b..329e3fd60 100644 --- a/yuthon_stock/views/inherit_stock_picking.xml +++ b/yuthon_stock/views/inherit_stock_picking.xml @@ -13,15 +13,18 @@ - + - - 确认入库 + + 确认入库 + + + 确认入库 1 @@ -50,6 +53,7 @@ 目的位置 + 1 供应商