Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/消息提醒优化

# Conflicts:
#	sf_sale/views/purchase_order_view.xml
This commit is contained in:
guanhuan
2024-12-23 14:06:11 +08:00
34 changed files with 555 additions and 93 deletions

View File

@@ -55,12 +55,15 @@ class ReSaleOrder(models.Model):
store=True, readonly=False, copy=False, precompute=True,
states=READONLY_FIELD_STATES, default=fields.Datetime.now)
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')], string='时效',
tracking=True)
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')],
default='normal',
string='时效', tracking=True)
order_code = fields.Char('平台订单号', readonly=True)
# 业务平台分配工厂后在智能工厂先创建销售订单
def sale_order_create(self, company_id, delivery_name, delivery_telephone, delivery_address,
deadline_of_delivery, payments_way, pay_way, state='sale'):
deadline_of_delivery, payments_way, pay_way, order_number, state='sale'):
now_time = datetime.datetime.now()
partner = self.get_customer()
data = {
@@ -76,6 +79,7 @@ class ReSaleOrder(models.Model):
'address_of_delivery': delivery_address,
'payments_way': payments_way,
'pay_way': pay_way,
'order_code': order_number,
}
if deadline_of_delivery:
# deadline_of_delivery字段存在为false字符串情况
@@ -158,10 +162,71 @@ class ReSaleOrder(models.Model):
if not line.tax_id:
raise UserError('请对【订单行】中的【税】进行选择')
consignment_purchase_order_count = fields.Integer(
"Number of consignment Purchase Order Generated",
compute='_compute_purchase_order_count')
@api.depends('order_line.purchase_line_ids.order_id')
def _compute_purchase_order_count(self):
for order in self:
order.purchase_order_count = len(order._get_purchase_orders().filtered(
lambda po: po.purchase_type not in ['consignment']))
order.consignment_purchase_order_count = len(order._get_purchase_orders().filtered(
lambda po: po.purchase_type in ['consignment']))
def action_view_purchase_orders(self):
"""
采购
"""
self.ensure_one()
purchase_order_ids = self._get_purchase_orders().filtered(
lambda po: po.purchase_type not in ['consignment']).ids
action = {
'res_model': 'purchase.order',
'type': 'ir.actions.act_window',
}
if len(purchase_order_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': purchase_order_ids[0],
})
else:
action.update({
'name': _("%s生成采购订单", self.name),
'domain': [('id', 'in', purchase_order_ids)],
'view_mode': 'tree,form',
})
return action
def action_view_consignment_purchase_orders(self):
"""
委外加工
"""
self.ensure_one()
consignment_purchase_order_ids = self._get_purchase_orders().filtered(
lambda po: po.purchase_type in ['consignment']).ids
action = {
'res_model': 'purchase.order',
'type': 'ir.actions.act_window',
}
if len(consignment_purchase_order_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': consignment_purchase_order_ids[0],
})
else:
action.update({
'name': _("%s生成委外加工订单", self.name),
'domain': [('id', 'in', consignment_purchase_order_ids)],
'view_mode': 'tree,form',
})
return action
class ResaleOrderLine(models.Model):
_inherit = 'sale.order.line'
# part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
part_name = fields.Char('零件名称', related='product_id.part_name', readonly=True)
model_glb_file = fields.Binary('模型的glb文件', compute='_compute_model_glb_file', store=True)
# product_template_id = fields.Many2one(
# string="产品",
@@ -199,6 +264,7 @@ class ProductTemplate(models.Model):
_inherit = 'product.template'
manual_quotation = fields.Boolean('人工编程', default=False)
part_name = fields.Char(string='零件名称', readonly=True)
class RePurchaseOrder(models.Model):
@@ -215,8 +281,22 @@ class RePurchaseOrder(models.Model):
compute='_compute_user_id',
store=True)
purchase_type = fields.Selection([('standard', '标准采购'), ('consignment', '委外加工')], string='采购类型',
default='standard')
purchase_type = fields.Selection(
[('standard', '标准采购'), ('consignment', '委外加工'), ('outsourcing', '工序外协'), ('outside', '外购订单')],
string='采购类型', default='standard')
origin_sale_id = fields.Many2one('sale.order', string='销售订单号', compute='_compute_origin_sale_id')
@api.depends('order_line.move_dest_ids.group_id.mrp_production_ids',
'order_line.move_ids.move_dest_ids.group_id.mrp_production_ids')
def _compute_origin_sale_id(self):
for purchase in self:
productions_ids = purchase._get_mrp_productions()
if productions_ids:
if productions_ids[0].sale_order_id:
purchase.origin_sale_id = productions_ids[0].sale_order_id.id
continue
purchase.origin_sale_id = False
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '预警'), ('overdue', '已逾期')],
string='交期状态',
@@ -259,7 +339,7 @@ class RePurchaseOrder(models.Model):
else:
server_template = self.env['product.template'].search(
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
('detailed_type', '=', 'service')])
('detailed_type', '=', 'service')])
server_product_process.append((0, 0, {
'product_id': server_template.product_variant_id.id,
'product_qty': 1,
@@ -325,6 +405,12 @@ class RePurchaseOrder(models.Model):
return last_overdue_order, last_warning_order
class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
part_name = fields.Char('零件名称', related='product_id.part_name', readonly=True)
# part_number = fields.Char('零件图号',related='product_id.part_number', readonly=True)
class ResPartnerToSale(models.Model):
_inherit = 'res.partner'