diff options
| author | Robin Heinz <rhe@odoo.com> | 2019-07-18 13:17:33 +0000 |
|---|---|---|
| committer | Pierre Masereel <pim@odoo.com> | 2019-07-23 07:41:20 +0000 |
| commit | 2eb1cde5348c6343fc0bd3fecc33ef7c6cca94ba (patch) | |
| tree | 3358ea0e2b78e2fdfbcc76a620c00fb01c0a5940 | |
| parent | 733fb360d25f885bd5c5b4688bbbc7f306f6f648 (diff) | |
[IMP] account, point_of_sale: take money from cash journal
When you have a cash journal, you have the opportunity to use a wizard
to easily create the statement. There are two wizards, one to add money
in the journal, and one to remove money.
To simplify the code and remove some duplication, we are now using only
one wizard, that will allow to add and/or remove money from the cash
journal.
TASK-ID: 1934784
| -rw-r--r-- | addons/account/wizard/pos_box.py | 24 | ||||
| -rw-r--r-- | addons/account/wizard/pos_box.xml | 34 | ||||
| -rw-r--r-- | addons/point_of_sale/views/pos_session_view.xml | 10 | ||||
| -rw-r--r-- | addons/point_of_sale/wizard/pos_box.py | 12 | ||||
| -rw-r--r-- | addons/point_of_sale/wizard/pos_box.xml | 9 |
5 files changed, 8 insertions, 81 deletions
diff --git a/addons/account/wizard/pos_box.py b/addons/account/wizard/pos_box.py index 14c12d32dee..3f1e9fe4c00 100644 --- a/addons/account/wizard/pos_box.py +++ b/addons/account/wizard/pos_box.py @@ -5,7 +5,7 @@ class CashBox(models.TransientModel): _register = False name = fields.Char(string='Reason', required=True) - # Attention, we don't set a domain, because there is a journal_type key + # Attention, we don't set a domain, because there is a journal_type key # in the context of the action amount = fields.Float(string='Amount', digits=0, required=True) @@ -36,26 +36,6 @@ class CashBox(models.TransientModel): record.write({'line_ids': [(0, False, values)]}) -class CashBoxIn(CashBox): - _name = 'cash.box.in' - _description = 'Cash Box In' - - ref = fields.Char('Reference') - - def _calculate_values_for_statement_line(self, record): - if not record.journal_id.company_id.transfer_account_id: - raise UserError(_("You have to define an 'Internal Transfer Account' in your cash register's journal.")) - return { - 'date': record.date, - 'statement_id': record.id, - 'journal_id': record.journal_id.id, - 'amount': self.amount or 0.0, - 'account_id': record.journal_id.company_id.transfer_account_id.id, - 'ref': '%s' % (self.ref or ''), - 'name': self.name, - } - - class CashBoxOut(CashBox): _name = 'cash.box.out' _description = 'Cash Box Out' @@ -68,7 +48,7 @@ class CashBoxOut(CashBox): 'date': record.date, 'statement_id': record.id, 'journal_id': record.journal_id.id, - 'amount': -amount if amount > 0.0 else amount, + 'amount': amount, 'account_id': record.journal_id.company_id.transfer_account_id.id, 'name': self.name, } diff --git a/addons/account/wizard/pos_box.xml b/addons/account/wizard/pos_box.xml index f72e2ec902b..d8efbc160ff 100644 --- a/addons/account/wizard/pos_box.xml +++ b/addons/account/wizard/pos_box.xml @@ -1,45 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> <odoo> <data> - <record model="ir.ui.view" id="cash_box_in_form"> - <field name="name">cash_box_in</field> - <field name="model">cash.box.in</field> - <field name="arch" type="xml"> - <form string="Put Money In"> - <separator string="Fill in this form if you put money in the cash register:" colspan="4" /> - <group> - <field name="name" class="oe_inline"/> - <field name="amount" class="oe_inline"/> - </group> - <footer> - <button name="run" string="Put Money In" type="object" class="btn-primary"/> - <button special="cancel" string="Cancel" class="btn-secondary"/> - </footer> - </form> - </field> - </record> - - <act_window - name="Put Money In" - res_model="cash.box.in" - binding_model="account.bank.statement" - view_mode="form" - target="new" - id="action_cash_box_in" /> - <record model="ir.ui.view" id="cash_box_out_form"> <field name="name">cash_box_out</field> <field name="model">cash.box.out</field> <field name="arch" type="xml"> - <form string="Take Money Out"> - <separator string="Describe why you take money from the cash register:"/> + <form string="Take Money In/Out"> + <separator string="Describe why you put/take money from the cash register:"/> <group> <field name="name" class="oe_inline"/> <field name="amount" class="oe_inline"/> </group> <footer> - <button name="run" string="Take Money Out" type="object" class="btn-primary"/> + <button name="run" string="Take Money In/Out" type="object" class="btn-primary"/> <button class="btn-secondary" special="cancel" string="Cancel" /> </footer> </form> @@ -47,7 +21,7 @@ </record> <act_window - name="Take Money Out" + name="Take Money In/Out" res_model="cash.box.out" binding_model="account.bank.statement" view_mode="form" diff --git a/addons/point_of_sale/views/pos_session_view.xml b/addons/point_of_sale/views/pos_session_view.xml index ca158b0b4a5..297a0f093e7 100644 --- a/addons/point_of_sale/views/pos_session_view.xml +++ b/addons/point_of_sale/views/pos_session_view.xml @@ -25,20 +25,12 @@ <sheet> <field name="cash_register_id" invisible="1"/> <div class="oe_button_box" name="button_box"> - <button class="oe_stat_button" name="%(action_pos_box_in)d" - type="action" icon="fa-level-down" - attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}"> - <div class="o_field_widget o_stat_info"> - <span class="o_stat_text">Put</span> - <span class="o_stat_text">Money In</span> - </div> - </button> <button class="oe_stat_button" name="%(action_pos_box_out)d" type="action" icon="fa-level-up" attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}"> <div class="o_field_widget o_stat_info"> <span class="o_stat_text">Take</span> - <span class="o_stat_text">Money Out</span> + <span class="o_stat_text">Money In/Out</span> </div> </button> <button name="open_cashbox" diff --git a/addons/point_of_sale/wizard/pos_box.py b/addons/point_of_sale/wizard/pos_box.py index aac7131045c..bd8aa751781 100644 --- a/addons/point_of_sale/wizard/pos_box.py +++ b/addons/point_of_sale/wizard/pos_box.py @@ -23,18 +23,6 @@ class PosBox(CashBox): return super(PosBox, self).run() -class PosBoxIn(PosBox): - _inherit = 'cash.box.in' - - def _calculate_values_for_statement_line(self, record): - values = super(PosBoxIn, self)._calculate_values_for_statement_line(record=record) - active_model = self.env.context.get('active_model', False) - active_ids = self.env.context.get('active_ids', []) - if active_model == 'pos.session' and active_ids: - values['ref'] = self.env[active_model].browse(active_ids)[0].name - return values - - class PosBoxOut(PosBox): _inherit = 'cash.box.out' diff --git a/addons/point_of_sale/wizard/pos_box.xml b/addons/point_of_sale/wizard/pos_box.xml index ae1aec6d997..4d5236f4efe 100644 --- a/addons/point_of_sale/wizard/pos_box.xml +++ b/addons/point_of_sale/wizard/pos_box.xml @@ -1,15 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <odoo> <act_window - id="action_pos_box_in" - name="Put Money In" - res_model="cash.box.in" - view_mode="form" - target="new"/> - - <act_window id="action_pos_box_out" - name="Take Money Out" + name="Take Money In/Out" res_model="cash.box.out" view_mode="form" target="new"/> |
