Skip to content

Commit

Permalink
[REV]getting back account_analytic_sequence_moduel, the one in OCA ha…
Browse files Browse the repository at this point in the history
…s much less features
  • Loading branch information
AaronHForgeFlow committed Apr 5, 2019
1 parent f974803 commit 44a8596
Show file tree
Hide file tree
Showing 15 changed files with 12 additions and 17 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
'views/account_analytic_account_view.xml',
'security/ir.model.access.csv',
],
'installable': False,
'installable': True,
'license': 'AGPL-3',
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create(self, vals):
get('account.analytic.account')
else:
new_code = self.env['ir.sequence'].get('account.analytic.account')
if 'code' in vals and not vals['code'] and new_code:
if not 'code' in vals and new_code:
vals['code'] = new_code
analytic_account = super(AccountAnalyticAccount, self).create(vals)
if 'sequence_ids' not in vals or\
Expand All @@ -87,7 +87,7 @@ def write(self, data):

@api.model
def map_sequences(self, new_analytic_account):
""" copy and map tasks from old to new analytic account """
""" copy and map tasks from old to new analytic account """
map_sequence_id = {}
account = self
for sequence in account.sequence_ids:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _inverse_number_next_actual(self):
padding = fields.Integer(
'Number Padding',
required=True,
default=0,
default=2,
help="OpenERP will automatically adds some '0' on"
" the left of the 'Next Number' to get the "
"required padding size."
Expand Down Expand Up @@ -276,19 +276,14 @@ def _next(self):
preferred_sequences = [s for s in self if
s.company_id.id == force_company]
seq = preferred_sequences[0] if preferred_sequences else self[0]
if seq.implementation == 'standard':
# pylint: disable=sql-injection
self._cr.execute(
"SELECT nextval('analytic_account_sequence_%05d')" % seq.id)
seq.number_next = self._cr.fetchone()
else:
self._cr.execute("SELECT number_next FROM "
"analytic_account_sequence WHERE id=%s"
"FOR UPDATE NOWAIT", (seq.id,))
self._cr.execute(
"UPDATE analytic_account_sequence "
"SET number_next=number_next+number_increment "
"WHERE id=%s ", (seq.id,))
# TODO do different for not standard implementation
self._cr.execute("SELECT number_next FROM "
"analytic_account_sequence WHERE id=%s"
"FOR UPDATE NOWAIT", (seq.id,))
self._cr.execute(
"UPDATE analytic_account_sequence "
"SET number_next=number_next+number_increment "
"WHERE id=%s ", (seq.id,))
d = self._interpolation_dict()
try:
interpolated_prefix = self._interpolate(seq.prefix, d)
Expand Down

0 comments on commit 44a8596

Please sign in to comment.