[IMP] point_of_sale

bzr revid: stw@openerp.com-20120511212912-htftara5senojo1w
This commit is contained in:
Stephane Wirtel 2012-05-11 23:29:12 +02:00
parent 0df2c9e559
commit 589b298125
6 changed files with 87 additions and 15 deletions

View File

@ -716,6 +716,7 @@ class account_journal(osv.osv):
_name = "account.journal"
_description = "Journal"
_columns = {
'with_last_closing_balance' : fields.boolean('Opening With Last Closing Balance'),
'name': fields.char('Journal Name', size=64, required=True),
'code': fields.char('Code', size=5, required=True, help="The code will be displayed on reports."),
'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'), ('cash', 'Cash'), ('bank', 'Bank and Cheques'), ('general', 'General'), ('situation', 'Opening/Closing Situation')], 'Type', size=32, required=True,
@ -746,6 +747,7 @@ class account_journal(osv.osv):
}
_defaults = {
'with_last_closing_balance' : False,
'user_id': lambda self, cr, uid, context: uid,
'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}

View File

@ -487,6 +487,7 @@
<separator string="Other Configuration" colspan="4"/>
<field name="centralisation"/>
<field name="entry_posted"/>
<field name="with_last_closing_balance" />
</group>
<group colspan="2" col="2">
<separator string="Invoicing Data" colspan="4"/>

View File

@ -31,7 +31,6 @@ class account_journal(osv.osv):
'closing_control': fields.boolean('Closing Control', help="If you want the journal should be control at closing, check this option"),
'amount_authorized_diff' : fields.float('Amount Authorized Difference'),
}
_defaults = {
'opening_control' : True,

View File

@ -198,6 +198,14 @@ class pos_session(osv.osv):
return result
def _compute_show_closing_control(self, cr, uid, ids, fieldnames, args, context=None):
result = dict.fromkeys(ids, False)
for session in self.browse(cr, uid, ids, context=context):
result[session.id] = any(journal.closing_control == True for journal in session.config_id.journal_ids)
return result
_columns = {
'config_id' : fields.many2one('pos.config', 'PoS',
required=True,
@ -242,14 +250,40 @@ class pos_session(osv.osv):
type='one2many', relation='account.cashbox.line',
string='CashBox Lines'),
'cash_register_date' : fields.related('cash_register_id', 'date', type='datetime', string='Started On'),
'cash_register_closing_date' : fields.related('cash_register_id', 'closing_date', type='datetime', string='Closed On'),
'cash_register_balance_end_real' : fields.related('cash_register_id', 'balance_end_real', type='float', digits_compute=dp.get_precision('Account'), string="Ending Balance"),
'cash_register_balance_start' : fields.related('cash_register_id', 'balance_start', type='float', digits_compute=dp.get_precision('Account'), string="Starting Balance"),
'cash_register_total_entry_encoding' : fields.related('cash_register_id', 'total_entry_encoding', string='Total Cash Transaction'),
'cash_register_balance_end' : fields.related('cash_register_id', 'balance_end', type='float', digits_compute=dp.get_precision('Account'), string="Computed Balance"),
'cash_register_balance_end_cash' : fields.related('cash_register_id', 'balance_end_cash', string='Closing Balance', help="Closing balance based on cashBox"),
'cash_register_difference' : fields.related('cash_register_id', 'difference', type='float', string='Difference'),
'cash_register_date' : fields.related('cash_register_id', 'date',
type='datetime',
string='Started On',
readonly=True),
'cash_register_closing_date' : fields.related('cash_register_id', 'closing_date',
type='datetime',
string='Closed On',
readonly=True),
'cash_register_balance_end_real' : fields.related('cash_register_id', 'balance_end_real',
type='float',
digits_compute=dp.get_precision('Account'),
string="Ending Balance",
readonly=True),
'cash_register_balance_start' : fields.related('cash_register_id', 'balance_start',
type='float',
digits_compute=dp.get_precision('Account'),
string="Starting Balance",
readonly=True),
'cash_register_total_entry_encoding' : fields.related('cash_register_id', 'total_entry_encoding',
string='Total Cash Transaction',
readonly=True),
'cash_register_balance_end' : fields.related('cash_register_id', 'balance_end',
type='float',
digits_compute=dp.get_precision('Account'),
string="Computed Balance",
readonly=True),
'cash_register_balance_end_cash' : fields.related('cash_register_id', 'balance_end_cash',
string='Closing Balance',
help="Closing balance based on cashBox",
readonly=True),
'cash_register_difference' : fields.related('cash_register_id', 'difference',
type='float',
string='Difference',
readonly=True),
'journal_ids' : fields.related('config_id', 'journal_ids',
type='many2many',
@ -259,6 +293,7 @@ class pos_session(osv.osv):
'order_ids' : fields.one2many('pos.order', 'session_id', 'Orders'),
'statement_ids' : fields.one2many('account.bank.statement', 'pos_session_id', 'Bank Statement', readonly=True),
'show_closing_control': fields.function(_compute_show_closing_control, method=True, type='boolean', string='Show Closing Control Button'),
}
_defaults = {
@ -290,7 +325,7 @@ class pos_session(osv.osv):
for session in self.browse(cr, uid, ids, context=None):
domain = [
('state', '!=', 'closed'),
('config_id', '=', session.config.id),
('config_id', '=', session.config_id.id),
('id', '!=', session.id),
]
@ -301,7 +336,7 @@ class pos_session(osv.osv):
return True
_constraints = [
_constraints2 = [
(_check_unicity, "You can create a new session, you have an existing and non closed session !", ['user_id', 'state']),
(_check_pos_config, "There is an existing session for the PoS Config", ['config_id']),
]
@ -373,6 +408,18 @@ class pos_session(osv.osv):
self._confirm_orders(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state' : 'closed'}, context=context)
def has_opening_control(self, cr, uid, ids, context=None):
return any(journal.opening_control == True
for session in self.browse(cr, uid, ids, context=context)
for journal in session.config_id.journal_ids)
def has_closing_control(self, cr, uid, ids, context=None):
result = any(journal.closing_control == True
for session in self.browse(cr, uid, ids, context=context)
for journal in session.config_id.journal_ids)
print "result: %r" % (result,)
return result
def _confirm_orders(self, cr, uid, ids, context=None):
wf_service = netsvc.LocalService("workflow")

View File

@ -884,7 +884,7 @@
</group>
<notebook colspan="4">
<page string="Cash">
<field name="cash_register_id" invisible="0" />
<field name="cash_register_id" invisible="1" />
<field name="opening_details_ids" colspan="4" nolabel="1" attrs="{'invisible' : [('state', 'not in', ('opening_control', 'opened'))], 'readonly' : [('state', '=', 'opened')]}">
<tree string="Opening Cashbox Lines" editable="bottom">
<field name="pieces" readonly="1" />
@ -942,14 +942,20 @@
</tree>
</field>
</page>
<page string="Debug">
<field name="show_closing_control" />
</page>
</notebook>
<group colspan="4" col="5">
<field name="state" /> <!-- widget="statusbar" statusbar_visible="new,opened,closed,posted" statusbar_colors='{"posted":"green"}'/> -->
<field name="state" widget="statusbar" statusbar_visible="opening_control,opened,closing_control,closed" statusbar_colors='{"posted":"green"}'/>
<!-- state:opening_control -> signal:open -> state:opened -> signal:cashbox_control -> state:closing_control -> signal:close -> state:close -->
<button name="open" type="workflow" string="Open" states="opening_control"/>
<button name="cashbox_control" type="workflow" string="Cashbox Control" states="opened" />
<button name="close" type="workflow" string="Close" states="closing_control" />
<button name="cashbox_control" type="workflow" string="Cashbox Control" states="opened" />
<!--
attrs="{'invisible' : [('show_closing_control', '=', False)]}"/>
-->
<button name="close" type="workflow" string="Close" states="closing_control,opened" />
</group>
</form>
</field>

View File

@ -122,6 +122,14 @@
<field name="act_to" ref="act_open" />
<field name="signal">open</field>
</record>
<!--
<record model="workflow.transition" id="trans_opening_control_to_open_automatic">
<field name="act_from" ref="act_opening_control" />
<field name="act_to" ref="act_open" />
<field name="signal" eval="False" />
<field name="condition">not has_opening_control()</field>
</record>
-->
<record model="workflow.transition" id="trans_open_to_closing_control">
<field name="act_from" ref="act_open" />
@ -129,6 +137,15 @@
<field name="signal">cashbox_control</field>
</record>
<!--
<record model="workflow.transition" id="trans_closing_control_to_close_automatic">
<field name="act_from" ref="act_closing_control" />
<field name="act_to" ref="act_close" />
<field name="signal" eval="False" />
<field name="condition">not has_closing_control()</field>
</record>
-->
<record model="workflow.transition" id="trans_closing_control_to_close">
<field name="act_from" ref="act_closing_control" />
<field name="act_to" ref="act_close" />