تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4714 أدوات العرض

 I have a list of Items from my Invoice. I decided to create a column for serial number. How to i get it to display numbers 1, 2, 3 etc for the products as i keep entering them? 

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

can you try the below code for odoo 12

in . py


class OrdinalNumber(models.Model):

_inherit = 'account.invoice.line'

number_sequence = fields.Integer(
compute='_compute_get_number',
store=True,
)

@api.depends('sequence', 'invoice_id')
def _compute_get_number(self):
for invoice in self.mapped('invoice_id'):
number_sequence = 1
for line in invoice.invoice_line_ids:
line.number_sequence = number_sequence
number_sequence += 1
in .xml

<record model="ir.ui.view" id="view_invoice_number_sequence_form">
<field name="name">account.invoice.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='sequence']" position="after">
<field name="number_sequence" string="No"/>
</xpath>
</field>
</record>

الصورة الرمزية
إهمال
أفضل إجابة

Hi Samuel,

You can add sequence function to line in order to achieve this. Check out this App for serial in order lines.

الصورة الرمزية
إهمال