[MIG] product_catch_weight: to v16, not completed migration, error on journal_id relation not exist

This commit is contained in:
Leo Pinedo
2022-10-28 18:02:36 +00:00
parent 932b13e677
commit d0f1bc2f15
6 changed files with 12 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
{
'name': 'Product Catch Weight',
'version': '12.0.1.0.0',
'version': '16.0.1.0.0',
'category': 'Warehouse',
'depends': [
'sale_stock',

View File

@@ -4,13 +4,12 @@ import logging
_logger = logging.getLogger(__name__)
class AccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
class AccountMoveLine(models.Model):
_name = "account.move.line"
catch_weight = fields.Float(string='Catch Weight', digits=(10, 4), compute='_compute_price', store=True)
catch_weight_uom_id = fields.Many2one('uom.uom', related='product_id.catch_weight_uom_id')
@api.one
@api.depends('price_unit', 'discount', 'invoice_line_tax_ids', 'quantity',
'product_id', 'invoice_id.partner_id', 'invoice_id.currency_id', 'invoice_id.company_id',
'invoice_id.date_invoice', 'invoice_id.date')

View File

@@ -2,7 +2,7 @@ from odoo import api, fields, models
class StockProductionLot(models.Model):
_inherit = 'stock.production.lot'
_inherit = 'stock.lot'
catch_weight_ratio = fields.Float(string='Catch Weight Ratio', digits=(10, 6), compute='_compute_catch_weight_ratio')
catch_weight = fields.Float(string='Catch Weight', digits=(10, 4))

View File

@@ -42,7 +42,7 @@ def _action_done(self):
# `use_create_lots` and `use_existing_lots`.
if ml.lot_name and not ml.lot_id:
lot_catch_weight = ml.catch_weight_uom_id._compute_quantity(ml.catch_weight, ml.product_id.catch_weight_uom_id, rounding_method='DOWN')
lot = self.env['stock.production.lot'].create(
lot = self.env['stock.lot'].create(
{'name': ml.lot_name, 'product_id': ml.product_id.id, 'catch_weight': lot_catch_weight}
)
ml.write({'lot_id': lot.id})

View File

@@ -35,7 +35,7 @@ class TestPicking(TransactionCase):
# def test_creation(self):
# self.productA.tracking = 'serial'
# lot = self.env['stock.production.lot'].create({
# lot = self.env['stock.lot'].create({
# 'product_id': self.productA.id,
# 'name': '123456789',
# })
@@ -49,7 +49,7 @@ class TestPicking(TransactionCase):
# self.productA.tracking = 'serial'
# picking_pick, picking_pack, picking_ship = self.create_pick_pack_ship()
# stock_location = self.env['stock.location'].browse(self.stock_location)
# lot = self.env['stock.production.lot'].create({
# lot = self.env['stock.lot'].create({
# 'product_id': self.productA.id,
# 'name': '123456789',
# 'catch_weight_ratio': 0.8,
@@ -58,7 +58,7 @@ class TestPicking(TransactionCase):
def test_so_invoice(self):
ref_weight = 45.0
lot = self.env['stock.production.lot'].create({
lot = self.env['stock.lot'].create({
'product_id': self.product1.id,
'name': '123456789',
'catch_weight': ref_weight,
@@ -89,12 +89,12 @@ class TestPicking(TransactionCase):
def test_so_invoice2(self):
ref_weight1 = 45.0
ref_weight2 = 51.0
lot1 = self.env['stock.production.lot'].create({
lot1 = self.env['stock.lot'].create({
'product_id': self.product1.id,
'name': '1-low',
'catch_weight': ref_weight1,
})
lot2 = self.env['stock.production.lot'].create({
lot2 = self.env['stock.lot'].create({
'product_id': self.product1.id,
'name': '1-high',
'catch_weight': ref_weight2,

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_production_lot_form_inherit" model="ir.ui.view">
<field name="name">stock.production.lot.form.inherit</field>
<field name="model">stock.production.lot</field>
<field name="name">stock.lot.form.inherit</field>
<field name="model">stock.lot</field>
<field name="inherit_id" ref="stock.view_production_lot_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='product_id']" position="after">