Browse Source

Merge 95514b83c5 into abad347945

pull/420/merge
Jacques-Etienne Baudoux 4 years ago
committed by GitHub
parent
commit
8d99fa6f81
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 44
      pos_round_payment/README.rst
  2. 2
      pos_round_payment/__init__.py
  3. 21
      pos_round_payment/__openerp__.py
  4. 27
      pos_round_payment/i18n/fr.po
  5. 2
      pos_round_payment/models/__init__.py
  6. 11
      pos_round_payment/models/account_journal.py
  7. 30
      pos_round_payment/models/pos_order.py
  8. 17
      pos_round_payment/reports/pos_receipt.xml
  9. 15
      pos_round_payment/views/account_journal.xml
  10. 1
      pos_round_payment/wizards/__init__.py
  11. 44
      pos_round_payment/wizards/pos_payment.py
  12. 1
      setup/hw_customer_display/odoo_addons/hw_customer_display
  13. 1
      setup/hw_telium_payment_terminal/odoo_addons/hw_telium_payment_terminal
  14. 1
      setup/pos_autoreconcile/odoo_addons/pos_autoreconcile
  15. 1
      setup/pos_customer_display/odoo_addons/pos_customer_display
  16. 1
      setup/pos_customer_required/odoo_addons/pos_customer_required
  17. 1
      setup/pos_default_empty_image/odoo_addons/pos_default_empty_image
  18. 1
      setup/pos_gift_ticket/odoo_addons/pos_gift_ticket
  19. 1
      setup/pos_invoice_journal/odoo_addons/pos_invoice_journal
  20. 1
      setup/pos_order_load/odoo_addons/pos_order_load
  21. 1
      setup/pos_order_picking_link/odoo_addons/pos_order_picking_link
  22. 1
      setup/pos_order_pricelist_change/odoo_addons/pos_order_pricelist_change
  23. 1
      setup/pos_payment_terminal/odoo_addons/pos_payment_terminal
  24. 1
      setup/pos_pricelist/odoo_addons/pos_pricelist
  25. 1
      setup/pos_product_template/odoo_addons/pos_product_template
  26. 1
      setup/pos_remove_pos_category/odoo_addons/pos_remove_pos_category

44
pos_round_payment/README.rst

@ -0,0 +1,44 @@
Point Of Sales Round Payment
============================
Allow to round payment method to 5 cents.
You can choose to round only the cash payment or all the payment method. You
need to enable the feature on the payment journal.
Rounding only occurs for B2C (i.e. if partner does not have a VAT number).
The pos order will be marked as paid with a difference between the total and
paid amount. When reconciling the posted entries after the end of the pos
session, the difference must be written on a write-off account.
Installation
============
To install this module, you just need to select the module and insure yourself dependencies are available.
Configuration
=============
No configuration to use this module.
Credits
=======
Contributors
------------
* Jacques-Etienne Baudoux <je@bcim.be> (BCIM sprl)
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

2
pos_round_payment/__init__.py

@ -0,0 +1,2 @@
from . import models
from . import wizards

21
pos_round_payment/__openerp__.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Jacques-Etienne Baudoux (BCIM sprl) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "POS Round Payment",
'version': '1.0',
'category': 'Point Of Sale',
'author': "BCIM",
'website': "https://www.bcim.be",
'depends': [
'point_of_sale',
],
'data': [
'views/account_journal.xml',
'reports/pos_receipt.xml',
],
'installable': True,
'auto_install': False,
'license': 'AGPL-3',
}

27
pos_round_payment/i18n/fr.po

@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_round_payment
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-30 23:35+0000\n"
"PO-Revision-Date: 2019-11-30 23:35+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_round_payment
#: field:account.journal,round_payment:0
msgid "Round Payment to 5 cents"
msgstr "Arrondir le paiement à 5 centimes"
#. module: pos_round_payment
#: view:website:point_of_sale.report_receipt
msgid "Rounded"
msgstr "Arrondi"

2
pos_round_payment/models/__init__.py

@ -0,0 +1,2 @@
from . import account_journal
from . import pos_order

11
pos_round_payment/models/account_journal.py

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Jacques-Etienne Baudoux (BCIM sprl) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields
class AccountJournal(models.Model):
_inherit = 'account.journal'
round_payment = fields.Boolean('Round Payment to 5 cents')

30
pos_round_payment/models/pos_order.py

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Jacques-Etienne Baudoux (BCIM sprl) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, models
class PosOrder(models.Model):
_inherit = "pos.order"
@api.multi
def test_paid(self):
"""A Point of Sale is paid when the sum
@return: True
"""
for order in self:
if order.lines and not order.amount_total:
return True
if not order.lines:
return False
if not order.statement_ids:
return False
amount = abs(order.amount_total-order.amount_paid)
if any(order.statement_ids.mapped('journal_id.round_payment')):
test = 0.021
else:
test = 0.009
if amount >= test:
return False
return True

17
pos_round_payment/reports/pos_receipt.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_pos_receipt" inherit_id="point_of_sale.report_receipt">
<xpath expr="//strong[@t-esc='formatLang(o.amount_total, currency_obj=res_company.currency_id)']" position="after">
<t t-if="abs(o.amount_total - o.amount_paid) >= 0.009">
<tr>
<td><strong>Rounded</strong></td>
<td class="text-right">
<strong t-esc="formatLang(o.amount_paid, currency_obj=res_company.currency_id)"/>
</td>
</tr>
</t>
</xpath>
</template>
</data>
</openerp>

15
pos_round_payment/views/account_journal.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_account_journal_pos_user_form">
<field name="name">POS Round Payment</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"/>
<field name="arch" type="xml">
<field name="journal_user" position="after">
<field name="round_payment"/>
</field>
</field>
</record>
</data>
</openerp>

1
pos_round_payment/wizards/__init__.py

@ -0,0 +1 @@
from . import pos_payment

44
pos_round_payment/wizards/pos_payment.py

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Jacques-Etienne Baudoux (BCIM sprl) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, models
class PosMakePayment(models.TransientModel):
_inherit = 'pos.make.payment'
@api.onchange('journal_id')
def onchange_journal(self):
active_id = self.env.context.get('active_id', False)
order = self.env['pos.order'].browse(active_id)
if (not order.partner_id.commercial_partner_id.vat
and self.journal_id.round_payment):
self.amount = round(self.amount * 20) / 20
else:
self.amount = order.amount_total - order.amount_paid
@api.multi
def check(self):
"""Check the order:
if the order is not paid: continue payment,
if the order is paid print ticket.
"""
active_id = self.env.context.get('active_id', False)
order = self.env['pos.order'].browse(active_id)
amount = order.amount_total - order.amount_paid
if self.journal_id.round_payment:
amount = round(amount * 20) / 20
if amount != 0.0:
data = self.read()[0]
data['journal'] = data['journal_id'][0]
self.pool['pos.order'].add_payment(
self._cr, self._uid, active_id, data, self._context)
if order.test_paid():
order.signal_workflow('paid')
return self.print_report()
return self.launch_payment()

1
setup/hw_customer_display/odoo_addons/hw_customer_display

@ -1 +0,0 @@
../../../hw_customer_display

1
setup/hw_telium_payment_terminal/odoo_addons/hw_telium_payment_terminal

@ -1 +0,0 @@
../../../hw_telium_payment_terminal

1
setup/pos_autoreconcile/odoo_addons/pos_autoreconcile

@ -1 +0,0 @@
../../../pos_autoreconcile

1
setup/pos_customer_display/odoo_addons/pos_customer_display

@ -1 +0,0 @@
../../../pos_customer_display

1
setup/pos_customer_required/odoo_addons/pos_customer_required

@ -1 +0,0 @@
../../../pos_customer_required

1
setup/pos_default_empty_image/odoo_addons/pos_default_empty_image

@ -1 +0,0 @@
../../../pos_default_empty_image

1
setup/pos_gift_ticket/odoo_addons/pos_gift_ticket

@ -1 +0,0 @@
../../../pos_gift_ticket

1
setup/pos_invoice_journal/odoo_addons/pos_invoice_journal

@ -1 +0,0 @@
../../../pos_invoice_journal

1
setup/pos_order_load/odoo_addons/pos_order_load

@ -1 +0,0 @@
../../../pos_order_load

1
setup/pos_order_picking_link/odoo_addons/pos_order_picking_link

@ -1 +0,0 @@
../../../pos_order_picking_link

1
setup/pos_order_pricelist_change/odoo_addons/pos_order_pricelist_change

@ -1 +0,0 @@
../../../pos_order_pricelist_change

1
setup/pos_payment_terminal/odoo_addons/pos_payment_terminal

@ -1 +0,0 @@
../../../pos_payment_terminal

1
setup/pos_pricelist/odoo_addons/pos_pricelist

@ -1 +0,0 @@
../../../pos_pricelist

1
setup/pos_product_template/odoo_addons/pos_product_template

@ -1 +0,0 @@
../../../pos_product_template

1
setup/pos_remove_pos_category/odoo_addons/pos_remove_pos_category

@ -1 +0,0 @@
../../../pos_remove_pos_category
Loading…
Cancel
Save