stock.production.lot对象修改为stock.lot,http新增验证返回

This commit is contained in:
jinling.yang
2022-12-12 10:04:16 +08:00
parent a18d55850a
commit 331f230974
4 changed files with 10 additions and 8 deletions

View File

@@ -4,13 +4,17 @@ import datetime
import time
import hashlib
from odoo import fields, models, api
from odoo.http import request, AuthenticationError
from odoo.http import request
__author__ = 'jinling.yang'
_logger = logging.getLogger(__name__)
class AuthenticationError(Exception):
pass
class Http(models.AbstractModel):
_inherit = 'ir.http'

View File

@@ -9,5 +9,3 @@ from . import stock

View File

@@ -51,10 +51,10 @@ class MrpProduction(models.Model):
def action_generate_serial(self):
self.ensure_one()
self.lot_producing_id = self.env['stock.production.lot'].create({
self.lot_producing_id = self.env['stock.lot'].create({
'product_id': self.product_id.id,
'company_id': self.company_id.id,
'name': self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
'name': self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) or self.env[
'ir.sequence'].next_by_code('stock.lot.serial'),
})
if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids:

View File

@@ -181,7 +181,7 @@ class StockRule(models.Model):
class ProductionLot(models.Model):
_inherit = 'stock.production.lot'
_inherit = 'stock.lot'
@api.model
def generate_lot_names1(self, display_name, first_lot, count):
@@ -217,10 +217,10 @@ class ProductionLot(models.Model):
def _get_next_serial(self, company, product):
"""Return the next serial number to be attributed to the product."""
if product.tracking == "serial":
last_serial = self.env['stock.production.lot'].search(
last_serial = self.env['stock.lot'].search(
[('company_id', '=', company.id), ('product_id', '=', product.id)],
limit=1, order='id DESC')
if last_serial:
return self.env['stock.production.lot'].generate_lot_names1(product.display_name, last_serial.name, 2)[
return self.env['stock.lot'].generate_lot_names1(product.display_name, last_serial.name, 2)[
1]
return "%s-%03d" % (product.display_name, 1)