@@ -11,6 +11,4 @@ class InheritResPartner(models.Model):
|
||||
partner_ids = self.env["res.partner"].browse(
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for partner in partner_ids:
|
||||
employee = self.env['hr.employee'].search([('name', '=', partner.display_name)])
|
||||
if employee:
|
||||
partner.is_employee = True
|
||||
partner.is_employee = True
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import inherit_stock_picking
|
||||
from . import Inherit_stock_picking_type
|
||||
from . import Inherit_stock_picking_type
|
||||
from . import inherit_stock_location
|
||||
@@ -0,0 +1,40 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models
|
||||
import json
|
||||
|
||||
|
||||
class InheritStockLocation(models.Model):
|
||||
_inherit = 'stock.location'
|
||||
|
||||
def update_stock(self):
|
||||
department_obj = self.env['hr.department']
|
||||
root_departments = department_obj.search([('child_ids', '=', False)])
|
||||
|
||||
company_departments = {}
|
||||
for dept in root_departments:
|
||||
company_id = dept.company_id.id
|
||||
if company_id not in company_departments:
|
||||
company_departments[company_id] = []
|
||||
company_departments[company_id].append(dept)
|
||||
|
||||
# 遍历分组后的公司和部门,创建库存位置
|
||||
for company_id, depts in company_departments.items():
|
||||
company = self.env['res.company'].browse(company_id)
|
||||
if not company:
|
||||
continue
|
||||
location_id = self.search([('complete_name', '=', company.name)])
|
||||
for dept in depts:
|
||||
existing_location = self.search([
|
||||
('name', '=', dept.name),
|
||||
('company_id', '=', company_id),
|
||||
('usage', '=', 'internal')
|
||||
], limit=1)
|
||||
if existing_location:
|
||||
continue
|
||||
self.create({
|
||||
'name': dept.name,
|
||||
'location_id': location_id.id,
|
||||
'complete_name': company.name,
|
||||
'usage': 'internal',
|
||||
'company_id': company_id,
|
||||
})
|
||||
@@ -8,6 +8,8 @@ class StockPicking(models.Model):
|
||||
|
||||
document_ids = fields.Many2many('ir.attachment', string="附件")
|
||||
employee_id = fields.Many2one('hr.employee', string="验收人")
|
||||
department_id = fields.Many2one('hr.department', string="部门")
|
||||
certifier_id = fields.Many2one('res.users', string="证明人")
|
||||
user_id = fields.Many2one('res.users', string="采购人员", compute="_compute_origin")
|
||||
json_display = fields.Char(
|
||||
string="物品详情",
|
||||
@@ -15,6 +17,13 @@ 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
|
||||
else:
|
||||
self.department_id = False
|
||||
|
||||
@api.depends(
|
||||
'move_ids_without_package.product_id',
|
||||
'move_ids_without_package.product_uom_qty',
|
||||
|
||||
@@ -12,10 +12,17 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="user_id" string="采购人员"/>
|
||||
<field name="employee_id" string="验收人" readonly="1"/>
|
||||
<field name="employee_id" string="验收人" required="1"/>
|
||||
<field name="certifier_id" required="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='picking_type_id']" position="after">
|
||||
<field name="department_id"/>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='button_validate']" position="attributes">
|
||||
<attribute name="string">确认入库</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='picking_properties']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user