I need to add Quantity field to journal items , the value of this field will be the same value of Done field of stock move , and if the journal entry created without stock move the value of Quantity field will be 1.
I created this code :
class AccountMove(models.Model):
    _inherit = 'account.move.line'
    qty=fields.Float(string="QTY",default=1)
Which function can i use to make the value of qty equal to Done quantity in case of Journal entry created by stock move?
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
Hi,
Can you please try with the below code. 
from odoo import models, fields, api
class AccountMoveLine(models.Model):
    _inherit = 'account.move.line'
    @api.model
    def create(self, vals):
        if 'stock_move_id' in vals:
            stock_move = self.env['stock.move'].browse(vals['stock_move_id'])
            vals['qty'] = stock_move.quantity_done
        return super(AccountMoveLine, self).create(vals)
Hope it helps
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيل| المنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
|---|---|---|---|---|
|  | 0 أكتوبر 25  | 165 | ||
|  | 2 أغسطس 25  | 3720 | ||
|  | 1 يوليو 25  | 1800 | ||
|  | 2 يوليو 25  | 2071 | ||
|  | 1 أغسطس 25  | 1153 | 
