I Want The Code In Compute because I Test Every Step, but it doesn't work
And thank you for helping me
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
Hi Yuossef,
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
sl_no = fields.Integer(string="Sl. No.", compute="_compute_sl_no")
@api.depends('order_id.order_line', 'order_id.order_line.display_type', 'order_id.order_line.sequence')
def _compute_sl_no(self):
for order in self.mapped('order_id'):
index = 0
for line in order.order_line:
if not line.display_type:
index += 1
line.sl_no = index
else:
line.sl_no = False
Hope this helps.
from odoo import models, fields, api
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
sequence_number = fields.Char(string='Sequence', compute='_compute_sequence')
@api.depends('order_id', 'order_id.state')
def _compute_sequence(self):
for line in self:
if line.order_id:
sequence = line.order_id.sequence_next()
line.sequence_number = sequence
sequence_number is a computed field that generates the sequence.
order_id.sequence_next() can be used to fetch the next available sequence for the order.
Make sure you also have a sequence defined for the sale.order model or use the built-in ir.sequence model to manage sequence generation. Adjust the logic as needed based on your specific requirements.
Add a new field in so and add the automation action
i = 1
for line in record.order_line.sorted(key=lambda l: l.sequence):
if line.display_type not in ('line_section', 'line_note'):
line.write({'x_studio_so_line_number': i})
i += 1
and this code for invoce
i = 1
for line in record.invoice_line_ids.sorted(key=lambda l: l.sequence):
if line.display_type not in ('line_section', 'line_note'):
line.write({'x_studio_line': i})
i += 1
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
Registrarse| Publicaciones relacionadas | Respuestas | Vistas | Actividad | |
|---|---|---|---|---|
|
|
1
oct 24
|
2436 | ||
|
|
2
sept 25
|
2883 | ||
|
|
1
ago 25
|
2294 | ||
|
|
1
ago 25
|
1227 | ||
|
|
0
jul 25
|
1248 |
What is "the code"?
In Advanced Properties, Compute
I mean this