[imp] account_move_batch_validate: first (partially) working state, yey!

This commit is contained in:
Leonardo Pistone
2014-01-13 10:12:48 +01:00
parent 7b28343e8c
commit b03b3d6a17
3 changed files with 42 additions and 17 deletions

View File

@@ -22,6 +22,9 @@
from openerp.osv import fields, orm
from openerp.addons.connector.queue.job import job
from openerp.addons.connector.session import ConnectorSessionHandler
class account_move(orm.Model):
@@ -36,3 +39,27 @@ class account_move(orm.Model):
help='Check this box to mark the move for batch posting'
),
}
def mark_for_posting(self, cr, uid, ids, context=None):
"""."""
session_hdl = ConnectorSessionHandler(cr.dbname, uid)
with session_hdl.session() as session:
for move_id in ids:
validate_one_move.delay(session, self._name, move_id)
print('===== PUT IN QUEUE!!!!! %s' % move_id)
# work with session
@job
def validate_one_move(session, model_name, move_id):
"""Press the button to validate a move. Return True.
This trivial function is there just to be called as a job with the delay
method.
"""
return session.pool['account.move'].button_validate(
session.cr,
session.uid,
[move_id]
)

View File

@@ -13,9 +13,6 @@
</field>
</record>
<record id="view_move_to_post_form" model="ir.ui.view">
<field name="name">view.move.to_post.form</field>
<field name="model">account.move</field>

View File

@@ -51,7 +51,21 @@ class AccountMoveMarker(orm.TransientModel):
move_obj = self.pool['account.move']
if wiz.action == 'mark':
import pdb;pdb.set_trace()
domain = []
if wiz.journal_ids:
domain.append((
'journal_id',
'in',
[journal.id for journal in wiz.journal_ids]
))
move_ids = move_obj.search(cr, uid, domain, context=context)
move_obj.write(cr, uid, move_ids, {'to_post': True})
move_obj.mark_for_posting(cr, uid, move_ids, context=context)
return {'type': 'ir.actions.act_window_close'}
elif wiz.action == 'unmark':
# TODO
raise NotImplementedError(
@@ -62,16 +76,3 @@ class AccountMoveMarker(orm.TransientModel):
raise NotImplementedError(
'Date and period filter are not implemented yet'
)
domain = []
if wiz.journal_ids:
domain.append((
'journal_id',
'in',
[journal.id for journal in wiz.journal_ids]
))
move_ids = move_obj.search(cr, uid, domain, context=context)
move_obj.write
for move in move_ids:
import pdb;pdb.set_trace()