[FIX] POS close session without cash register
bzr revid: fp@openerp.com-20121103171225-nlp53s0aenamdhcg
This commit is contained in:
parent
fa90c9e771
commit
74476c8e22
|
@ -78,7 +78,7 @@ class account_cash_statement(osv.osv):
|
||||||
"""
|
"""
|
||||||
res = {}
|
res = {}
|
||||||
for statement in self.browse(cr, uid, ids, context=context):
|
for statement in self.browse(cr, uid, ids, context=context):
|
||||||
if statement.journal_id.type not in ('cash',):
|
if (statement.journal_id.type not in ('cash',)) or (not statement.journal_id.cash_control):
|
||||||
continue
|
continue
|
||||||
start = end = 0
|
start = end = 0
|
||||||
for line in statement.details_ids:
|
for line in statement.details_ids:
|
||||||
|
|
|
@ -296,49 +296,53 @@ class pos_session(osv.osv):
|
||||||
]
|
]
|
||||||
|
|
||||||
def create(self, cr, uid, values, context=None):
|
def create(self, cr, uid, values, context=None):
|
||||||
config_id = values.get('config_id', False) or False
|
context = context or {}
|
||||||
if config_id:
|
config_id = values.get('config_id', False) or context.get('default_config_id', False)
|
||||||
# journal_id is not required on the pos_config because it does not
|
if not config_id:
|
||||||
# exists at the installation. If nothing is configured at the
|
raise osv.except_osv( _('Error!'),
|
||||||
# installation we do the minimal configuration. Impossible to do in
|
_("You should assign a Point of Sale to your session."))
|
||||||
# the .xml files as the CoA is not yet installed.
|
|
||||||
jobj = self.pool.get('pos.config')
|
|
||||||
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
|
||||||
if not pos_config.journal_id:
|
|
||||||
jid = jobj.default_get(cr, uid, ['journal_id'], context=context)['journal_id']
|
|
||||||
if jid:
|
|
||||||
jobj.write(cr, uid, [pos_config.id], {'journal_id': jid}, context=context)
|
|
||||||
else:
|
|
||||||
raise osv.except_osv( _('error!'),
|
|
||||||
_("Unable to open the session. You have to assign a sale journal to your point of sale."))
|
|
||||||
|
|
||||||
# define some cash journal if no payment method exists
|
# journal_id is not required on the pos_config because it does not
|
||||||
if not pos_config.journal_ids:
|
# exists at the installation. If nothing is configured at the
|
||||||
journal_proxy = self.pool.get('account.journal')
|
# installation we do the minimal configuration. Impossible to do in
|
||||||
cashids = journal_proxy.search(cr, uid, [('journal_user', '=', True), ('type','=','cash')], context=context)
|
# the .xml files as the CoA is not yet installed.
|
||||||
|
jobj = self.pool.get('pos.config')
|
||||||
|
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
||||||
|
if not pos_config.journal_id:
|
||||||
|
jid = jobj.default_get(cr, uid, ['journal_id'], context=context)['journal_id']
|
||||||
|
if jid:
|
||||||
|
jobj.write(cr, uid, [pos_config.id], {'journal_id': jid}, context=context)
|
||||||
|
else:
|
||||||
|
raise osv.except_osv( _('error!'),
|
||||||
|
_("Unable to open the session. You have to assign a sale journal to your point of sale."))
|
||||||
|
|
||||||
|
# define some cash journal if no payment method exists
|
||||||
|
if not pos_config.journal_ids:
|
||||||
|
journal_proxy = self.pool.get('account.journal')
|
||||||
|
cashids = journal_proxy.search(cr, uid, [('journal_user', '=', True), ('type','=','cash')], context=context)
|
||||||
|
if not cashids:
|
||||||
|
cashids = journal_proxy.search(cr, uid, [('type', '=', 'cash')], context=context)
|
||||||
if not cashids:
|
if not cashids:
|
||||||
cashids = journal_proxy.search(cr, uid, [('type', '=', 'cash')], context=context)
|
cashids = journal_proxy.search(cr, uid, [('journal_user','=',True)], context=context)
|
||||||
if not cashids:
|
|
||||||
cashids = journal_proxy.search(cr, uid, [('journal_user','=',True)], context=context)
|
|
||||||
|
|
||||||
jobj.write(cr, uid, [pos_config.id], {'journal_ids': [(6,0, cashids)]})
|
jobj.write(cr, uid, [pos_config.id], {'journal_ids': [(6,0, cashids)]})
|
||||||
|
|
||||||
|
|
||||||
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
pos_config = jobj.browse(cr, uid, config_id, context=context)
|
||||||
bank_statement_ids = []
|
bank_statement_ids = []
|
||||||
for journal in pos_config.journal_ids:
|
for journal in pos_config.journal_ids:
|
||||||
bank_values = {
|
bank_values = {
|
||||||
'journal_id' : journal.id,
|
'journal_id' : journal.id,
|
||||||
'user_id' : uid,
|
'user_id' : uid,
|
||||||
}
|
}
|
||||||
statement_id = self.pool.get('account.bank.statement').create(cr, uid, bank_values, context=context)
|
statement_id = self.pool.get('account.bank.statement').create(cr, uid, bank_values, context=context)
|
||||||
bank_statement_ids.append(statement_id)
|
bank_statement_ids.append(statement_id)
|
||||||
|
|
||||||
values.update({
|
values.update({
|
||||||
'name' : pos_config.sequence_id._next(),
|
'name' : pos_config.sequence_id._next(),
|
||||||
'statement_ids' : [(6, 0, bank_statement_ids)],
|
'statement_ids' : [(6, 0, bank_statement_ids)],
|
||||||
'config_id': config_id
|
'config_id': config_id
|
||||||
})
|
})
|
||||||
|
|
||||||
return super(pos_session, self).create(cr, uid, values, context=context)
|
return super(pos_session, self).create(cr, uid, values, context=context)
|
||||||
|
|
||||||
|
@ -390,7 +394,7 @@ class pos_session(osv.osv):
|
||||||
def wkf_action_closing_control(self, cr, uid, ids, context=None):
|
def wkf_action_closing_control(self, cr, uid, ids, context=None):
|
||||||
for session in self.browse(cr, uid, ids, context=context):
|
for session in self.browse(cr, uid, ids, context=context):
|
||||||
for statement in session.statement_ids:
|
for statement in session.statement_ids:
|
||||||
if statement != session.cash_register_id and statement.balance_end != statement.balance_end_real:
|
if (statement != session.cash_register_id) and (statement.balance_end != statement.balance_end_real):
|
||||||
self.pool.get('account.bank.statement').write(cr, uid, [statement.id], {'balance_end_real': statement.balance_end})
|
self.pool.get('account.bank.statement').write(cr, uid, [statement.id], {'balance_end_real': statement.balance_end})
|
||||||
return self.write(cr, uid, ids, {'state' : 'closing_control', 'stop_at' : time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
|
return self.write(cr, uid, ids, {'state' : 'closing_control', 'stop_at' : time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
|
|
||||||
<record model="workflow.transition" id="trans_open_to_close">
|
<record model="workflow.transition" id="trans_open_to_close">
|
||||||
<field name="act_from" ref="act_open" />
|
<field name="act_from" ref="act_open" />
|
||||||
<field name="act_to" ref="act_close" />
|
<field name="act_to" ref="act_closing_control" />
|
||||||
<field name="signal">close</field>
|
<field name="signal">close</field>
|
||||||
<field name="condition">cash_control == False</field>
|
<field name="condition">cash_control == False</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -163,5 +163,13 @@
|
||||||
<field name="signal">close</field>
|
<field name="signal">close</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="workflow.transition" id="trans_closing_control_to_close_no_control">
|
||||||
|
<field name="act_from" ref="act_closing_control" />
|
||||||
|
<field name="act_to" ref="act_close" />
|
||||||
|
<field name="condition">cash_control == False</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
Loading…
Reference in New Issue