Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4913 Lượt xem

Hello,

I added a field into product.template model called "pieces_inside_1_cartoon" and I want this field to appear into the tree of stock.view_picking_form, so when the user chooses a product, the pieces_inside_1_cartoon appears.
I keep getting errors concerning that matter.

------------------------------------------------

Here is the product.template model I inderited:

from odoo import models, fields, api


class StockPicking(models.Model):
_inherit = 'stock.picking'

product_id = fields.Many2one("product.template")
pcs_per_cartoon = fields.Integer(related="product_id.pcs_per_cartoon", string="Number of cartons")
# pcs_per_cartoon = fields.Integer(string="Number of cartons")

--------------------------------------------------------

Here is the view I inherited:



view.picking.form.inherited
stock.picking

1001




position="after">




-----------------------------------------------

Here is the error I keep getting:

Field "pcs_per_cartoon" does not exist in model "stock.move"

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi

You have added your fields in model stock.picking and given the view in tree view of stock.move

So inherit the model stock.move and add your custom fields there , because product_id is present in stock.move and not in stock.picking

Hope it helps,

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi,

Thank you for the reply.

I tried it before but it generates another error:

field = model.pool[model_name]._fields[name]

KeyError: 'product_tmpl_id' - - -

Thats because product_id in stock.move points to product.product and not product.template

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 21
4320
2
thg 5 25
5181
1
thg 7 24
2252
6
thg 5 24
21752
0
thg 11 20
2437