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

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)

and this code on xml:


<?xml version="1.0"?>
<odoo>

<record id="view_move_inherit" model="ir\.ui\.view"\>
\ />\ \ \ \ \ \ \ \ \<field\ name="name"\>
view\.move\.inherit\</field\>
\ />\ \ \ \ \ \ \ \ \<field\ name="model"\>account\.move\</field\>
\ \ \ \ \ \ \ \ \<field\ name="inherit_id"\ ref="account\.view_move_form"/\>
\ \ \ \ \ \ \ \ \<field\ name="arch"\ type="xml"\>
\ \ \ \ \ \ \ \ \ \ \ \ \<xpath\ expr="//notebook/page/field\[@name='line_ids'\]/tree/field\[@name='partner_id'\]"\ position="after"\>
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \<field\ name="qty"/\>
\ \ \ \ \ \ \ \ \ \ \ \ \</xpath\>
\ \ \ \ \ \ \ \ \</field\>
\ \ \ \ \</record\>

\ \ \ \ \<record\ id="view_move_list_inherit"\ model="
ir\.ui\.view"\>
\ />\ \ \ \ \ \ \ \ \<field\ name="name"\>
view\.move\.list\.inherit\</field\>
\ />\ \ \ \ \ \ \ \ \<field\ name="model"\>
account.move.line</field>
/> <field name="inherit_id" ref="account.view_move_line_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="qty"/>
</xpath>
</field>
</record>


</odoo>





How can i make the value of Quantity field the same value of done in case of journal entry created by stock move?

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

Hi,

You can inherit the _prepare_account_move_vals function in the stock.move model and pass the custom/base field value from stock move to related journal entry.


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
4014
0
thg 11 23
1562
1
thg 7 23
2099
4
thg 12 22
22473
0
thg 8 25
295