Skip to content
Permalink
Browse files

[IMP] POS: amount_authorized_diff moved to pos.config

should be defined on the POS, not per journal
moved amount_authorized_diff setting on the pos.config

Task: #1934784
Closes: #31551
  • Loading branch information...
mgh-odoo committed Mar 4, 2019
1 parent 6ce0193 commit b03cecf31141aa47fdc98ae455db2db86e704ed9
@@ -9,10 +9,6 @@ class AccountJournal(models.Model):

journal_user = fields.Boolean('Use in Point of Sale',
help="Check this box if this journal define a payment method that can be used in a point of sale.")
amount_authorized_diff = fields.Float('Amount Authorized Difference',
help="This field depicts the maximum difference allowed between the ending balance and the theoretical cash when "
"closing a session, for non-POS managers. If this maximum is reached, the user will have an error message at "
"the closing of his session saying that he needs to contact his manager.")

@api.model
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
@@ -175,6 +175,10 @@ def _compute_iface_start_categ_domain_ids(self):
is_posbox = fields.Boolean("PosBox")
is_header_or_footer = fields.Boolean("Header & Footer")
module_pos_hr = fields.Boolean(help="Show employee login screen")
amount_authorized_diff = fields.Float('Amount Authorized Difference',
help="This field depicts the maximum difference allowed between the ending balance and the theoretical cash when "
"closing a session, for non-POS managers. If this maximum is reached, the user will have an error message at "
"the closing of his session saying that he needs to contact his manager.")

def _compute_is_installed_account_accountant(self):
account_accountant = self.env['ir.module.module'].sudo().search([('name', '=', 'account_accountant'), ('state', '=', 'installed')])
@@ -276,10 +276,10 @@ def action_pos_session_close(self):
company_id = session.config_id.company_id.id
ctx = dict(self.env.context, force_company=company_id, company_id=company_id)
for st in session.statement_ids:
if abs(st.difference) > st.journal_id.amount_authorized_diff:
if abs(st.difference) > session.config_id.amount_authorized_diff:
# The pos manager can close statements with maximums.
if not self.user_has_groups("point_of_sale.group_pos_manager"):
raise UserError(_("Your ending balance is too different from the theoretical cash closing (%.2f), the maximum allowed is: %.2f. You can contact your manager to force it.") % (st.difference, st.journal_id.amount_authorized_diff))
raise UserError(_("Your ending balance is too different from the theoretical cash closing (%.2f), the maximum allowed is: %.2f. You can contact your manager to force it.") % (st.difference, session.config_id.amount_authorized_diff))
if (st.journal_id.type not in ['bank', 'cash']):
raise UserError(_("The journal type for your payment method should be bank or cash."))
st.with_context(ctx).sudo().button_confirm_bank()
@@ -8,15 +8,6 @@
<xpath expr="//field[@name='type']" position="after">
<field name="journal_user" attrs="{'invisible': [('type', 'not in', ['bank', 'cash'])]}"/>
</xpath>
<xpath expr="//notebook[last()]" position="inside">
<page string="Point of Sale" attrs="{'invisible': [('journal_user', '=', False)]}">
<group>
<group name="amount_authorized" attrs="{'invisible': [('type', '!=', 'cash')]}">
<field name="amount_authorized_diff"/>
</group>
</group>
</page>
</xpath>
</field>
</record>
<record id="view_account_bank_journal_form_inherited_pos" model="ir.ui.view">
@@ -343,9 +343,13 @@
</div>
<div class="content-group mt16" attrs="{'invisible': [('cash_control', '=', False)]}">
<div class="row mt16">
<label string="Default Opening" for="proxy_ip" class="col-lg-3 o_light_label" />
<label string="Default Opening" for="proxy_ip" class="col-lg-4 o_light_label" />
<field name="default_cashbox_lines_ids" widget="many2many_tags" context="{'form_view_ref': 'point_of_sale.account_cashbox_line_view_form'}"/>
</div>
<div class="row">
<label for="amount_authorized_diff" class="col-lg-4 o_light_label" />
<field name="amount_authorized_diff"/>
</div>
<div>
<button type="action" name="%(account_cashbox_line_action)d" string="Opening/Closing Values" class="btn-link" icon="fa-arrow-right"/>
</div>
@@ -71,12 +71,16 @@
<record id="view_account_journal_pos_user_form" model="ir.ui.view">
<field name="name">POS Journal</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"></field>
<field name="inherit_id" ref="account.view_account_journal_form"></field>
<field name="arch" type="xml">
<xpath expr="//group[@name='amount_authorized']" position="after">
<group attrs="{'invisible': [('type', '!=', 'bank')]}">
<field name="pos_mercury_config_id"/>
</group>
<xpath expr="//notebook[last()]" position="inside">
<page string="Point of Sale" attrs="{'invisible': [('journal_user', '=', False)]}">
<group>
<group attrs="{'invisible': [('type', '!=', 'bank')]}">
<field name="pos_mercury_config_id"/>
</group>
</group>
</page>
</xpath>
</field>
</record>

0 comments on commit b03cecf

Please sign in to comment.
You can’t perform that action at this time.