How can I create a strict sequence from the XML?

I’m trying to create an XML to set up a strict sequence in ir.sequence.strict, but it’s not working. It generates an error when I execute ‘tryto-admin -c conf -d database --all’. However, when it’s a sequence in ir.sequence, it generates without any issue, I just change the reference to the model.

<?xml version="1.0" encoding="utf-8"?>
<!-- Sequences for invoice -->
        <record id="seq_type_invoice_order" model="ir.sequence.type">
            <field name="name">order invoice</field>
        <record id="seq_invoice_order" model="ir.sequence.strict">
            <field name="name">order invo</field>
            <field name="sequence_type" ref="seq_type_invoice_order" ></field>
            <field name="padding">0</field>
            <field name="company" eval="1"/>
			<field name="number_increment"  eval="1"/>

    <data noupdate="1">
        <record model="invoice.sequences.invoice_sequence"
            <field name="invoice_sequence" ref="seq_invoice_order"/>

thank you

What is exactly the error?

C(tryton) root@localhost:~# tryto-admin -c /opt/tryton/config/trytond.conf -d tryton --all
Traceback (most recent call last):
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/", line 464, in parse_xmlstream
  File "/usr/lib64/python3.11/xml/sax/", line 111, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib64/python3.11/xml/sax/", line 125, in parse
  File "/usr/lib64/python3.11/xml/sax/", line 217, in feed
    self._parser.Parse(data, isFinal)
  File "/builddir/build/BUILD/Python-3.11.7/Modules/pyexpat.c", line 468, in EndElement
  File "/usr/lib64/python3.11/xml/sax/", line 336, in end_element
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/", line 519, in endElement
    self.taghandler = self.taghandler.endElement(name)
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/", line 314, in endElement
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/", line 627, in import_record
    raise ParsingError(
trytond.convert.ParsingError: wrong model 'ir.sequence.strict': account_es_es_vf.seq_invoice_order

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/tryton/bin/trytond-admin", line 31, in <module>
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/", line 57, in run
    pool.init(update=options.update, lang=list(lang),
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/", line 167, in init
    restart = not load_modules(
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/modules/", line 384, in load_modules
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/modules/", line 352, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/modules/", line 203, in load_module_graph
  File "/opt/tryton/lib64/python3.11/site-packages/trytond/", line 466, in parse_xmlstream
    raise ParsingError("in %s" % self.current_state()) from e
trytond.convert.ParsingError: in record 'account_es_es_vf.seq_invoice_order'

It is just that your field invoice_sequence is not a Many2One to ir.sequence.strict.

However, if I only use ‘ir.sequence’, the code works and generates the fields in non-strict sequences.

from trytond.pool import Pool
from trytond.pool import PoolMeta
from trytond.model import (ModelView, ModelSingleton, ModelSQL, ValueMixin, MultiValueMixin, fields)
from trytond.pyson import Id

invoice_sequence = fields.Many2One(
    'ir.sequence.strict', 'invoice order', required=True,
    domain=[('sequence_type', '=', Id(
        'account_es_es_vf', 'seq_type_invoice_order'))])
class InvoiceSequences(ModelSingleton, ModelSQL, ModelView, MultiValueMixin):
    'Invoice Sequences'
    __name__ = 'invoice.sequences'

    invoice_sequence = fields.MultiValue(invoice_sequence)

    def default_invoice_sequence(cls, **pattern):
        pool = Pool()
        ModelData = pool.get('')
            return ModelData.get_id('account_es_es_vf', 'seq_invoice_order')
        except KeyError:
            return None

class ConfigurationSequence(ModelSQL, ValueMixin):
    'invoice Configuration Sequence'
    __name__ = 'invoice.sequences.invoice_sequence'
    invoice_sequence= invoice_sequence

    def check_xml_record(cls, records, values):
        return True

Indeed you just pollute your database by changing the model of the XML record without changing the ID.

Thanks, but I also changed the ID in the XML. I’ll try with a new empty database; it’s the only thing I haven’t tried yet. Thanks

Thank you very much. If it’s a database poisoning/contamination issue, it works in the previous state of the database.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.