mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of Forte Payment integration and parts of hr_payroll_payment to support it.
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
Adds the ability to register a payment on a payslip.
|
Adds the ability to register a payment on a payslip.
|
||||||
""",
|
""",
|
||||||
'website': 'https://hibou.io/',
|
'website': 'https://hibou.io/',
|
||||||
'depends': ['hr_payroll_account'],
|
'depends': ['hr_payroll_account', 'payment'],
|
||||||
'data': [
|
'data': [
|
||||||
'hr_payroll_register_payment.xml',
|
'hr_payroll_register_payment.xml',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ class HrPayrollRegisterPaymentWizard(models.TransientModel):
|
|||||||
journal_id = fields.Many2one('account.journal', string='Payment Method', required=True, domain=[('type', 'in', ('bank', 'cash'))])
|
journal_id = fields.Many2one('account.journal', string='Payment Method', required=True, domain=[('type', 'in', ('bank', 'cash'))])
|
||||||
company_id = fields.Many2one('res.company', related='journal_id.company_id', string='Company', readonly=True, required=True)
|
company_id = fields.Many2one('res.company', related='journal_id.company_id', string='Company', readonly=True, required=True)
|
||||||
payment_method_id = fields.Many2one('account.payment.method', string='Payment Type', required=True)
|
payment_method_id = fields.Many2one('account.payment.method', string='Payment Type', required=True)
|
||||||
|
payment_method_code = fields.Char(related='payment_method_id.code',
|
||||||
|
help="Technical field used to adapt the interface to the payment type selected.", readonly=True)
|
||||||
|
payment_transaction_id = fields.Many2one('payment.transaction', string="Payment Transaction")
|
||||||
|
payment_token_id = fields.Many2one('payment.token', string="Saved payment token",
|
||||||
|
domain=[('acquirer_id.capture_manually', '=', False)],
|
||||||
|
help="Note that tokens from acquirers set to only authorize transactions (instead of capturing the amount) are not available.")
|
||||||
amount = fields.Monetary(string='Payment Amount', required=True, default=_default_amount)
|
amount = fields.Monetary(string='Payment Amount', required=True, default=_default_amount)
|
||||||
currency_id = fields.Many2one('res.currency', string='Currency', required=True, default=lambda self: self.env.user.company_id.currency_id)
|
currency_id = fields.Many2one('res.currency', string='Currency', required=True, default=lambda self: self.env.user.company_id.currency_id)
|
||||||
payment_date = fields.Date(string='Payment Date', default=fields.Date.context_today, required=True)
|
payment_date = fields.Date(string='Payment Date', default=fields.Date.context_today, required=True)
|
||||||
@@ -63,6 +69,24 @@ class HrPayrollRegisterPaymentWizard(models.TransientModel):
|
|||||||
hide_payment_method = fields.Boolean(compute='_compute_hide_payment_method',
|
hide_payment_method = fields.Boolean(compute='_compute_hide_payment_method',
|
||||||
help="Technical field used to hide the payment method if the selected journal has only one available which is 'manual'")
|
help="Technical field used to hide the payment method if the selected journal has only one available which is 'manual'")
|
||||||
|
|
||||||
|
@api.onchange('partner_id')
|
||||||
|
def _onchange_partner_id(self):
|
||||||
|
res = {}
|
||||||
|
if self.partner_id:
|
||||||
|
partners = self.partner_id | self.partner_id.commercial_partner_id | self.partner_id.commercial_partner_id.child_ids
|
||||||
|
res['domain'] = {
|
||||||
|
'payment_token_id': [('partner_id', 'in', partners.ids), ('acquirer_id.capture_manually', '=', False)]}
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
@api.onchange('payment_method_id', 'journal_id')
|
||||||
|
def _onchange_payment_method(self):
|
||||||
|
if self.payment_method_code == 'electronic':
|
||||||
|
self.payment_token_id = self.env['payment.token'].search(
|
||||||
|
[('partner_id', '=', self.partner_id.id), ('acquirer_id.capture_manually', '=', False)], limit=1)
|
||||||
|
else:
|
||||||
|
self.payment_token_id = False
|
||||||
|
|
||||||
@api.one
|
@api.one
|
||||||
@api.constrains('amount')
|
@api.constrains('amount')
|
||||||
def _check_amount(self):
|
def _check_amount(self):
|
||||||
@@ -106,7 +130,9 @@ class HrPayrollRegisterPaymentWizard(models.TransientModel):
|
|||||||
'amount': self.amount,
|
'amount': self.amount,
|
||||||
'currency_id': self.currency_id.id,
|
'currency_id': self.currency_id.id,
|
||||||
'payment_date': self.payment_date,
|
'payment_date': self.payment_date,
|
||||||
'communication': self.communication
|
'communication': self.communication,
|
||||||
|
'payment_transaction_id': self.payment_transaction_id.id if self.payment_transaction_id else False,
|
||||||
|
'payment_token_id': self.payment_token_id.id if self.payment_token_id else False,
|
||||||
})
|
})
|
||||||
payment.post()
|
payment.post()
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
<field name="journal_id" widget="selection"/>
|
<field name="journal_id" widget="selection"/>
|
||||||
<field name="hide_payment_method" invisible="1"/>
|
<field name="hide_payment_method" invisible="1"/>
|
||||||
<field name="payment_method_id" widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)]}"/>
|
<field name="payment_method_id" widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)]}"/>
|
||||||
|
<field name="payment_method_code" invisible="1"/>
|
||||||
|
<field name="payment_token_id" options="{'no_create': True}"
|
||||||
|
attrs="{'invisible': [('payment_method_code', '!=', 'electronic')],
|
||||||
|
'required': [('payment_method_code', '=', 'electronic')]}"/>
|
||||||
<label for="amount"/>
|
<label for="amount"/>
|
||||||
<div name="amount_div" class="o_row">
|
<div name="amount_div" class="o_row">
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
@@ -42,6 +46,7 @@
|
|||||||
<group>
|
<group>
|
||||||
<field name="payment_date"/>
|
<field name="payment_date"/>
|
||||||
<field name="communication"/>
|
<field name="communication"/>
|
||||||
|
<field name="payment_transaction_id"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
|||||||
Reference in New Issue
Block a user