I have a module that generate the sale order name.
I need to change the initials in the sequence according to the current company.
if self.env.company.name == 'example':
rec.name = 'EXMP' + str(rec.country) + str(year_date) + '-' + str(rec.type) + '-' + str(source) + vendor_code + str(rec.seq_num)
else:
rec.name = 'NTT' + str(rec.country) + str(year_date) + '-' + str(rec.type) + '-' + str(source) + vendor_code + str(rec.seq_num)
Case:
User (Dan) has access to two companies {example} and {example2}. {example} is user (Dan) default company.
User (Dan) switched to {example2} company.
When creating a sale order, everything seems fine and the name of the sale order will appear as [NTT********] when the current company is {example2} until I press [SAVE]. Instead, the name of the sale order will change to [EXMP********].
tried the same scenario with other user (Joe) who has the same access except that the default company is {example2}. This time the sale order name will stay as [NTT********] after saving.
It appears that the sale order is taking the user default company when saving (create)?
I wonder what should I add to insure that the code works properly?
haven’t found a similar case on the forum yet.