修改表面工艺外协字段类型

This commit is contained in:
jinling.yang
2023-03-28 21:26:02 +08:00
parent bf010e2cca
commit 93c9287717
3 changed files with 113 additions and 13 deletions

View File

@@ -3,8 +3,9 @@ from collections import defaultdict, namedtuple
from odoo.addons.stock.models.stock_rule import ProcurementException
from re import findall as regex_findall
from re import split as regex_split
from odoo import SUPERUSER_ID, _, api, models
from odoo import SUPERUSER_ID, _, api, models
from odoo.tools import float_compare
from odoo.exceptions import UserError
class StockRule(models.Model):
@@ -226,3 +227,87 @@ class ProductionLot(models.Model):
return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[
1]
return "%s-%03d" % (product.name, 1)
# class ResPurchaseOrder(models.Model):
# _inherit = 'purchase.order'
#
# # def button_approve(self, force=False):
# # result = super().button_approve(force=force)
# # self._create_picking_RES()
# # return result
#
# # @api.depends('order_line.move_ids')
# # def _compute_subcontracting_resupply_picking_count(self):
# # for purchase in self:
# # purchase.subcontracting_resupply_picking_count = len(purchase._get_subcontracting_resupplies_new())
# #
# # def _get_subcontracting_resupplies_new(self):
# # moves_subcontracted = self.order_line.move_ids.filtered(lambda m: m.is_subcontract)
# # # subcontracted_productions = moves_subcontracted.move_orig_ids.production_id
# # return moves_subcontracted.picking_id
#
# def _prepare_picking_RES(self):
# if not self.group_id:
# self.group_id = self.group_id.create({
# 'name': self.name,
# 'partner_id': self.partner_id.id
# })
# if not self.partner_id.property_stock_supplier.id:
# raise UserError(_("You must set a Vendor Location for this partner %s", self.partner_id.name))
# picking_type_id_res = self.env['stock.picking.type'].search(
# [('sequence_code', '=', 'RES'), ('barcode', '=', 'WH-RESUPPLY')])
# return {
# 'picking_type_id': picking_type_id_res.id if picking_type_id_res else self.picking_type_id.id,
# 'partner_id': self.partner_id.id,
# 'user_id': False,
# 'date': self.date_order,
# 'origin': self.name,
# 'location_dest_id': self._get_destination_location(),
# 'location_id': self.partner_id.property_stock_supplier.id,
# 'company_id': self.company_id.id,
# }
#
# def _create_picking(self):
# StockPicking = self.env['stock.picking']
# for order in self.filtered(lambda po: po.state in ('purchase', 'done')):
# if any(product.type in ['product', 'consu'] for product in order.order_line.product_id):
# order = order.with_company(order.company_id)
# pickings = order.picking_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
# if not pickings:
# if order.order_line.product_id.categ_type == '胚料':
# res = order._prepare_picking_RES()
# else:
# res = order._prepare_picking()
# picking = StockPicking.with_user(SUPERUSER_ID).create(res)
# pickings = picking
# else:
# picking = pickings[0]
# moves = order.order_line._create_stock_moves(picking)
# moves = moves.filtered(lambda x: x.state not in ('done', 'cancel'))._action_confirm()
# seq = 0
# for move in sorted(moves, key=lambda move: move.date):
# seq += 5
# move.sequence = seq
# moves._action_assign()
# # Get following pickings (created by push rules) to confirm them as well.
# forward_pickings = self.env['stock.picking']._get_impacted_pickings(moves)
# (pickings | forward_pickings).action_confirm()
# picking.message_post_with_view('mail.message_origin_link',
# values={'self': picking, 'origin': order},
# subtype_id=self.env.ref('mail.mt_note').id)
# return True
#
#
# class ResPurchaseOrderLine(models.Model):
# _inherit = 'purchase.order.line'
#
# def _create_stock_moves(self, picking):
# values = []
# for line in self.filtered(lambda l: not l.display_type):
# for val in line._prepare_stock_moves(picking):
# val['production_id'] = 10
# values.append(val)
# line.move_dest_ids.created_purchase_line_id = False
#
# return self.env['stock.move'].create(values)