Hello,
I have inherited and added a field in stock.move and I have added it to account.move.line as a related field yet it is not being displayed in the latter module.
How can I go about this.
Thanks in advance.
My code.
class StockMove (models. Model):
_inherit = 'stock. move'
def _prepare_account_move_line ( self , move ):
res = super (AccountMoveLine , self )._prepare_account_move_line( move )
res. update({
"net_weight" : self . net_weight
})
return res
net_weight = fields.Integer( string = "Net Weight" , store = True )
class AccountMoveLine (models.Model):
_inherit = 'account.move.line'
net_weight = fields.Integer(related='move_id.net_weight', string="Net Weight", store=True, readonly=False)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi Jay,
1/ - 'account.move.line' doesn't have 'stock_move_id' field
- but 'account.move' have 'stock_move_id' field
2/ related fields doesn't need to call compute
try this:
class StockMove (models.Model):
_inherit = 'stock.move'
net_weight = fields.Integer(string="Net Weight", store=True)
class AccountMove (models.Model):
_inherit = 'account.move'
net_weight = fields.Integer(related='stock_move_id.net_weight', string="Net Weight")
Regards!
Hi Jason,
Still not displaying the values from stock.move.
I am trying to get the above net_weight values to display in account.move.line below.
Hi Jay,
If you want to create an invoice from sale order after set net_weight and post stock.picking you can do like that:
class StockMove (models.Model):
_inherit = 'stock.move'
net_weight = fields.Integer(string="Net Weight", store=True)
class AccountMoveLine (models.Model):
_inherit = 'account.move.line'
net_weight = fields.Integer(string="Net Weight")
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
def _prepare_invoice_line(self, **optional_values):
res = super()._prepare_invoice_line(**optional_values)
res['net_weight'] = self.move_ids.net_weight
return res
Hope this help!
Thanks a lot, Jason, works fine now.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 5 25
|
2448 | ||
|
1
thg 4 25
|
3469 | ||
|
1
thg 4 25
|
4297 | ||
|
1
thg 4 25
|
1779 | ||
|
4
thg 3 25
|
6885 |