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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
2
Odpowiedzi
4716
Widoki
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.
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się