hi i change the create method of account method to have a sequence number like sale module and it 's work in draft status , know i want to in posted status to have the same sequence like draft i inherit the next_by_id and _next from ir.sequence but it doesn't work
this is what i do
name_seq = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, index=True, default=lambda self: _('New'))
@api.model
def create(self, vals):
if vals.get('name_seq', _('New')) == _('New'):
vals['name_seq'] = self.env['ir.sequence'].next_by_code('sequence.piece') or _('New')
result = super(AccountMove, self).create(vals)
return result
in the post methode in next_by_id i want to call my name_seq
new_name = sequence.with_context(ir_sequence_date=move.date).next_by_id()
class IrSequence(models.Model):
_inherit = "ir.sequence"
name_seq = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, index=True,
default=lambda self: _('New'))
def _next(self):
""" Returns the next number in the preferred sequence in all the ones given in self."""
dt = fields.Date.today()
seq_date = self.env['account.move'].browse(('id', '=', self.name_seq))
return seq_date
@api.multi
def next_by_id(self):
""" Draw an interpolated string using the specified sequence."""
self.check_access_rights('read')
return self._next()
don't work any help please