[ADD] pos_pax: for Odoo 11.0

This commit is contained in:
Jared Kipe
2020-11-20 14:24:53 -08:00
parent ae794f2703
commit 736483fe5e
13 changed files with 1275 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from . import pos_pax

61
pos_pax/models/pos_pax.py Normal file
View File

@@ -0,0 +1,61 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from odoo import models, fields, api, _
from odoo.tools.float_utils import float_compare
class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
pax_card_number = fields.Char(string='Card Number', help='Masked credit card.')
pax_txn_id = fields.Char(string='PAX Transaction ID')
class AccountJournal(models.Model):
_inherit = 'account.journal'
pos_use_pax = fields.Boolean(string='Use POS PAX Terminal',
help='When used in POS, communicate with PAX Terminal for transactions.')
class PosConfig(models.Model):
_inherit = 'pos.config'
pax_endpoint = fields.Char(string='PAX Endpoint',
help='Endpoint for PAX device (include protocol (http or https) and port). '
'e.g. http://192.168.1.101:10009')
class PosOrder(models.Model):
_inherit = "pos.order"
@api.model
def _payment_fields(self, ui_paymentline):
fields = super(PosOrder, self)._payment_fields(ui_paymentline)
fields.update({
'pax_card_number': ui_paymentline.get('pax_card_number'),
'pax_txn_id': ui_paymentline.get('pax_txn_id'),
})
return fields
def add_payment(self, data):
statement_id = super(PosOrder, self).add_payment(data)
statement_lines = self.env['account.bank.statement.line'].search([('statement_id', '=', statement_id),
('pos_statement_id', '=', self.id),
('journal_id', '=', data['journal'])])
statement_lines = statement_lines.filtered(lambda line: float_compare(line.amount, data['amount'],
precision_rounding=line.journal_currency_id.rounding) == 0)
# we can get multiple statement_lines when there are >1 credit
# card payments with the same amount. In that case it doesn't
# matter which statement line we pick, just pick one that
# isn't already used.
for line in statement_lines:
if not line.pax_card_number:
line.pax_card_number = data.get('pax_card_number')
line.pax_txn_id = data.get('pax_txn_id')
break
return statement_id

20
pos_pax/models/update.py Normal file
View File

@@ -0,0 +1,20 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from odoo import models
class PublisherWarrantyContract(models.AbstractModel):
_inherit = 'publisher_warranty.contract'
def _get_hibou_modules(self):
modules = super(PublisherWarrantyContract, self)._get_hibou_modules()
try:
self.env.cr.execute(
'SELECT COUNT(*) FROM pos_config WHERE pax_endpoint != \'\' AND pax_endpoint IS NOT NULL')
pax_count = self.env.cr.fetchone()[0] or 0
modules.update({
'pos_pax': pax_count,
})
except:
pass
return modules