Hello
The code you provided is a Python code snippet that updates the "x_total_price_tax_inc" field of an Odoo record with a value calculated based on the "list_price" field. To define a compute method that achieves the same result, you can do the following:
@api.depends('list_price')
def _compute_total_price_tax_inc(self):
for record in self:
record.x_total_price_tax_inc = record.list_price * 1.20
Explanation:
The @api.depends decorator indicates that this method depends on the "list_price" field of the record, which means that it should be automatically recalculated whenever the "list_price" field is changed.
The _compute_total_price_tax_inc method is a compute method that takes a single argument, which is the recordset that this method is being called on.
The for record in self: loop iterates over each record in the recordset.
The record.x_total_price_tax_inc = record.list_price * 1.20 line calculates the "x_total_price_tax_inc" field based on the "list_price" field and assigns the result to the "x_total_price_tax_inc" field of the current record.
Once the method has finished iterating over all records in the recordset, the "x_total_price_tax_inc" field of each record will have been updated based on its "list_price" field.
Thanks & Regards,
CandidRoot Solutions Pvt. Ltd.
Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat