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

Hi and new to odoo develpment since i was using the interface all the time.

i wanted to create a custom module that the user can create a recourd then add some infroration in an "order line format"  but if the recourd existed he would be able to import that would add a new lines "order line"

so my question is first is it possible to import to `line`

if so how to create a line 

I tryed reading the docs but could not figure it out






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

Hi,

It seems you are asking how to add one2many fields to your model, if so please see this video explaining the same: How to Add One2many Fields In Odoo

Thanks

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

Thank you for your quick reply.

Yes you are right but first is it possible to import new to a line/one2many

Tác giả

I am using odoo 13 so when I followed odoo mates tutorial I got this error

`invf = comodel._fields[self.inverse_name]`

which I solved using `_columns` the old API? but can't figure out how to user the New API `_fields`

can one2many be import

Câu trả lời hay nhất

You can filter sale order line by sale order id many2one in your custom module.

check my working code below,



class custommodule(models.Model):
_name = 'custom.module'

_description = "custom module"
sale_order_id = fields.Many2one('sale.order', index=True, required=True)
order_lines = fields.One2many('sale.order.line', 'line_id', 'Order Lines', domain="[('order_id','=','sale_order_id.id')]")

@api.onchange('sale_order_id')
def onchange_sale_order_id(self):
self.order_lines = self.sale_order_id.order_line


class mymodule_line(models.Model):
_inherit = 'sale.order.line'
line_id = fields.Many2one('custom.module', string='Order')


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 6 20
4662
1
thg 8 21
2333
1
thg 4 21
3773
0
thg 4 21
2265
1
thg 12 21
3478