what i'm trying to do here is creating a new field dimension that gets value from a field in the [stock.move] model this approach doesn't work i don't know why and it's not getting any errors from the python file the only error from the xpath tag at the xml file
this is models.py file
xx_Custom_Invoice(models.Model):
_inherit = 'account.move'
dimension = fields.Char(String="XxX", compute='get_data')
def get_data(self):
stock_move = self.env['stock.move']
for move in self:
picking = stock_move.picking_id
if move.id != picking.account_move_ids:
continue
for line in move:
line.update({
'dimension': line.dimension,
})
here is the views.xml
<record id="xx_account_move_view_inherit" model="ir.ui.view" >
<field name="name">account.move.view.inherit</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[@name='invoice_line_ids']/tree/field[@name='product_id']" position="after">
<field name="dimension"/>
</xpath>
</field>
</record>
There is an issue here:
stock_move = self.env['stock.move']
for move in self:
stock_move
here is an empty recordset, so no iteration will happen in the for loop.
You probably to use search()
to fetch the record you want to operate on:
stock_move = self.env['stock.move'].search(<DOMAIN>)
for move in self: