diff options
| author | Stephane Wirtel <stw@openerp.com> | 2012-09-05 17:05:38 +0200 |
|---|---|---|
| committer | Stephane Wirtel <stw@openerp.com> | 2012-09-05 17:05:38 +0200 |
| commit | 97de9d6d3ffcd5417d73d89d2145b7bab736d35d (patch) | |
| tree | af48447d38f4eee4afaa00fb6ca5fb28b89b2fb3 | |
| parent | 29a931656681029526b55ca87f75fc6dedde97dc (diff) | |
[FIX] point_of_sale: Set the right account for the internal account.
[REF] point_of_sale: Review the code for the Take Money Out and Push Money In.
[FIX] point_of_sale: Can post a session with an order in the invoiced state.
bzr revid: stw@openerp.com-20120905150538-v9ex7wehyebft7tu
| -rw-r--r-- | addons/account/demo/account_minimal.xml | 2 | ||||
| -rw-r--r-- | addons/account/wizard/pos_box.py | 22 | ||||
| -rw-r--r-- | addons/point_of_sale/point_of_sale.py | 2 | ||||
| -rw-r--r-- | addons/point_of_sale/point_of_sale_view.xml | 10 | ||||
| -rw-r--r-- | addons/point_of_sale/wizard/pos_box.py | 27 |
5 files changed, 41 insertions, 22 deletions
diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index b7bc34a3e35..94b3d2d4085 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -383,7 +383,7 @@ <field name="type">cash</field> <field name="profit_account_id" model="account.account" ref="rsa" /> <field name="loss_account_id" model="account.account" ref="rsa" /> - <field name="internal_account_id" model="account.account" ref="chart0" /> + <field name="internal_account_id" model="account.account" ref="rsa" /> <field name="with_last_closing_balance" eval="True" /> <field name="cash_control" eval="True" /> <field name="view_id" ref="account_journal_bank_view"/> diff --git a/addons/account/wizard/pos_box.py b/addons/account/wizard/pos_box.py index b4254b5ba84..b5d1cc37776 100644 --- a/addons/account/wizard/pos_box.py +++ b/addons/account/wizard/pos_box.py @@ -40,6 +40,10 @@ class CashBox(osv.osv_memory): return {} + def _create_bank_statement_line(self, cr, uid, box, record, context=None): + values = self._compute_values_for_statement_line(cr, uid, box, record, context=context) + return self.pool.get('account.bank.statement.line').create(cr, uid, values, context=context) + class CashBoxIn(CashBox): _name = 'cash.box.in' @@ -49,30 +53,24 @@ class CashBoxIn(CashBox): 'ref' : fields.char('Reference', size=32), }) - def _create_bank_statement_line(self, cr, uid, box, record, context=None): - absl_proxy = self.pool.get('account.bank.statement.line') - - values = { + def _compute_values_for_statement_line(self, cr, uid, box, record, context=None): + return { 'statement_id' : record.id, 'journal_id' : record.journal_id.id, 'account_id' : record.journal_id.internal_account_id.id, 'amount' : box.amount or 0.0, - 'ref' : "%s" % (box.ref or ''), + 'ref' : '%s' % (box.ref or ''), 'name' : box.name, } - return absl_proxy.create(cr, uid, values, context=context) - CashBoxIn() class CashBoxOut(CashBox): _name = 'cash.box.out' - def _create_bank_statement_line(self, cr, uid, box, record, context=None): - absl_proxy = self.pool.get('account.bank.statement.line') - + def _compute_values_for_statement_line(self, cr, uid, box, record, context=None): amount = box.amount or 0.0 - values = { + return { 'statement_id' : record.id, 'journal_id' : record.journal_id.id, 'account_id' : record.journal_id.internal_account_id.id, @@ -80,6 +78,4 @@ class CashBoxOut(CashBox): 'name' : box.name, } - return absl_proxy.create(cr, uid, values, context=context) - CashBoxOut() diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 24c482bd53c..2d6d8b92da1 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -422,7 +422,7 @@ class pos_session(osv.osv): self.pool.get('pos.order')._create_account_move_line(cr, uid, order_ids, session, move_id, context=context) for order in session.order_ids: - if order.state != 'paid': + if order.state not in ('paid', 'invoiced'): raise osv.except_osv( _('Error!'), _("You cannot confirm all orders of this session, because they have not the 'paid' status")) diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml index 4a56c0dda3c..6dffbd82d19 100644 --- a/addons/point_of_sale/point_of_sale_view.xml +++ b/addons/point_of_sale/point_of_sale_view.xml @@ -897,7 +897,7 @@ </group> <newline/> - <group string="Opening Cash Control" attrs="{'invisible' : ['|', ('cash_control', '=', False),('state', '=', 'closed')]}"> + <group string="Opening Cash Control" attrs="{'invisible' : ['|', ('cash_control', '=', False),('state', 'in', ('opened', 'closing_control'))]}"> <field name="opening_details_ids" nolabel="1" colspan="2" attrs="{'readonly' : [('state', 'not in', ('opening_control',))]}"> <tree string="Opening Cashbox Lines" editable="bottom"> <field name="pieces" readonly="1" /> @@ -906,7 +906,7 @@ </tree> </field> </group> - <group string="Closing Cash Control" attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', '!=', 'closing_control')]}"> + <group string="Closing Cash Control" attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', 'in', ('opening_control', 'opened'))]}"> <field name="details_ids" nolabel="1" colspan="2"> <tree string="Cashbox Lines" editable="bottom"> <field name="pieces" readonly="1" /> @@ -916,14 +916,14 @@ </field> </group> - <div attrs="{'invisible': [('state', '!=', 'closed')]}"> + <div attrs="{'invisible' : ['|', ('cash_control', '=', False),('state', 'in', ('opened', 'closing_control'))]}"> <group class="oe_subtotal_footer oe_right"> <field name="cash_register_balance_start" readonly="1" string="Opening Balance" class="oe_subtotal_footer_separator"/> <field name="cash_register_total_entry_encoding" attrs="{'invisible' : [('state', '=', 'opening_control')]}" string="+ Transactions"/> <field name="cash_register_balance_end" attrs="{'invisible' : [('state', '=', 'opening_control')]}" string="= Theorical Balance"/> </group> <div class="oe_clear"/> - <div attrs="{'invisible' : [('cash_journal_id', '=', False)]}" class="oe_view_nocontent" groups="point_of_sale.group_pos_manager"> + <div attrs="{'invisible' : ['|', ('cash_journal_id', '=', False), ('state', '!=', 'opening_control')]}" class="oe_view_nocontent" groups="point_of_sale.group_pos_manager"> <p class="oe_view_nocontent_create"> You can define another list of available currencies on the <i>Cash Registers</i> tab of the <b><field name="cash_journal_id" class="oe_inline"/></b> @@ -933,7 +933,7 @@ </div> - <group class="oe_subtotal_footer oe_right" attrs="{'invisible' : [('state', '!=', 'closed')]}"> + <group class="oe_subtotal_footer oe_right" attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', 'in', ('opening_control', 'opened'))]}"> <field name="cash_register_balance_end_real" class="oe_subtotal_footer_separator"/> <field name="cash_register_difference" class="oe_subtotal_footer_separator"/> </group> diff --git a/addons/point_of_sale/wizard/pos_box.py b/addons/point_of_sale/wizard/pos_box.py index 8c3b0aa4607..2d1c1a8e0cf 100644 --- a/addons/point_of_sale/wizard/pos_box.py +++ b/addons/point_of_sale/wizard/pos_box.py @@ -15,8 +15,7 @@ class PosBox(CashBox): active_ids = context.get('active_ids', []) or [] if active_model == 'pos.session': - records = self.pool.get(active_model).browse(cr, uid, context.get('active_ids', []) or [], context=context) - + records = self.pool.get(active_model).browse(cr, uid, active_ids, context=context) bank_statements = [record.cash_register_id for record in records if record.cash_register_id] if not bank_statements: @@ -30,6 +29,30 @@ class PosBox(CashBox): class PosBoxIn(PosBox): _inherit = 'cash.box.in' + def _compute_values_for_statement_line(self, cr, uid, box, record, context=None): + values = super(PosBoxIn, self)._compute_values_for_statement_line(cr, uid, box, record, context=context) + + active_model = context.get('active_model', False) or False + active_ids = context.get('active_ids', []) or [] + + if active_model == 'pos.session': + session = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)[0] + values['ref'] = session.name + + return values + + class PosBoxOut(PosBox): _inherit = 'cash.box.out' + def _compute_values_for_statement_line(self, cr, uid, box, record, context=None): + values = super(PosBoxOut, self)._compute_values_for_statement_line(cr, uid, box, record, context=context) + + active_model = context.get('active_model', False) or False + active_ids = context.get('active_ids', []) or [] + + if active_model == 'pos.session': + session = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)[0] + values['ref'] = session.name + + return values |
