Hello, I have a module with this code in stock.picking
# models/stock_picking.py
from odoo import fields, models, api
class StockPicking(models.Model):
_inherit = 'stock.picking'
invoice_status = fields.Boolean(string='Invoice Status', default=False)
@api.depends('sale_id.invoice_ids')
def _compute_invoice_status(self):
for picking in self:
invoices = picking.sale_id.invoice_ids.filtered(lambda inv: inv.state != 'cancel')
picking.invoice_status = bool(invoices)
and this is the xml
stock.picking.form.inherit
stock.picking
If I create a sales order, and confirm it but do not create its corresponding invoice, I want the boolean field to remain False, but if an invoice is created for the sales order, I want it to go to True automatically... .
I tried with that code and some others and it didn't work, can you guide me?
Thanks and sorry for bothering.