Skip to content
Snippets Groups Projects
Commit 85bcd6fd authored by Ravi Patel's avatar Ravi Patel Committed by Martin Trigaux
Browse files

[REF] account,payment_paypal: Remove the 'paypal_account' field

This field was relevant before the salepocalypse, it is no longer.
Replaced by generic payment providers instead of putting paypal payment methods
in account.

Remove it from the res.company and res.config model
Remove the method `_migrate_paypal_account` as it was used to find paypal
accounts based on the removed field

Closes #11231, task-22286
parent 4fed1026
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,6 @@ class ResCompany(models.Model):
('round_globally', 'Round Globally'),
], default='round_per_line', string='Tax Calculation Rounding Method',
help="If you select 'Round per Line' : for each tax, the tax amount will first be computed and rounded for each PO/SO/invoice line and then these rounded amounts will be summed, leading to the total amount for that tax. If you select 'Round Globally': for each tax, the tax amount will be computed for each PO/SO/invoice line, then these amounts will be summed and eventually this total tax amount will be rounded. If you sell with tax included, you should choose 'Round per line' because you certainly want the sum of your tax-included line subtotals to be equal to the total amount with taxes.")
paypal_account = fields.Char(string='Paypal Account', size=128, help="Paypal username (usually email) for receiving online payments.")
currency_exchange_journal_id = fields.Many2one('account.journal', string="Exchange Gain or Loss Journal", domain=[('type', '=', 'general')])
income_currency_exchange_account_id = fields.Many2one('account.account', related='currency_exchange_journal_id.default_credit_account_id',
string="Gain Exchange Rate Account", domain="[('internal_type', '=', 'other'), ('deprecated', '=', False), ('company_id', '=', id)]")
......
......@@ -24,10 +24,6 @@ class AccountConfigSettings(models.TransientModel):
help='Check this box if this company is a legal entity.')
currency_id = fields.Many2one('res.currency', related='company_id.currency_id', required=True,
string='Default company currency', help="Main currency of the company.")
paypal_account = fields.Char(related='company_id.paypal_account', size=128, string='Paypal account',
help="""Paypal account (email) for receiving online payments (credit card, etc.)
If you set a paypal account, the customer will be able to pay your invoices or quotations
with a button \"Pay with Paypal\" in automated emails or through the Odoo portal.""")
company_footer = fields.Text(related='company_id.rml_footer', string='Bank accounts footer preview',
readonly=True, help="Bank accounts as printed in the footer of each printed document")
......@@ -144,7 +140,6 @@ class AccountConfigSettings(models.TransientModel):
self.expects_chart_of_accounts = company.expects_chart_of_accounts
self.currency_id = company.currency_id
self.transfer_account_id = company.transfer_account_id
self.paypal_account = company.paypal_account
self.company_footer = company.rml_footer
self.tax_calculation_rounding_method = company.tax_calculation_rounding_method
self.bank_account_code_prefix = company.bank_account_code_prefix
......
......@@ -229,10 +229,7 @@
<group>
<label for="id" string="Payments"/>
<div name="customer_payments">
<div name='payment_acquirer'>
<label for="paypal_account"/>
<field name="paypal_account" placeholder="e.g. sales@odoo.com" class="oe_inline"/>
</div>
<div name='payment_acquirer'/>
</div>
</group>
</form>
......
......@@ -17,6 +17,5 @@
<field name="paypal_api_password">dummy</field>
</record>
<function model="payment.acquirer" name="_migrate_paypal_account"/>
</data>
</openerp>
# -*- coding: utf-8 -*-
import paypal
import res_company
......@@ -62,25 +62,6 @@ class AcquirerPaypal(osv.Model):
'paypal_api_enabled': False,
}
def _migrate_paypal_account(self, cr, uid, context=None):
""" COMPLETE ME """
cr.execute('SELECT id, paypal_account FROM res_company')
res = cr.fetchall()
for (company_id, company_paypal_account) in res:
if company_paypal_account:
company_paypal_ids = self.search(cr, uid, [('company_id', '=', company_id), ('provider', '=', 'paypal')], limit=1, context=context)
if company_paypal_ids:
self.write(cr, uid, company_paypal_ids, {'paypal_email_account': company_paypal_account}, context=context)
else:
paypal_view = self.pool['ir.model.data'].get_object(cr, uid, 'payment_paypal', 'paypal_acquirer_button')
self.create(cr, uid, {
'name': 'Paypal',
'provider': 'paypal',
'paypal_email_account': company_paypal_account,
'view_template_id': paypal_view.id,
}, context=context)
return True
def paypal_compute_fees(self, cr, uid, id, amount, currency_id, country_id, context=None):
""" Compute paypal fees.
......
# -*- coding: utf-8 -*-
from openerp.osv import fields, osv
class ResCompany(osv.Model):
_inherit = "res.company"
def _get_paypal_account(self, cr, uid, ids, name, arg, context=None):
Acquirer = self.pool['payment.acquirer']
company_id = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.id
paypal_ids = Acquirer.search(cr, uid, [
('website_published', '=', True),
('name', 'ilike', 'paypal'),
('company_id', '=', company_id),
], limit=1, context=context)
if paypal_ids:
paypal = Acquirer.browse(cr, uid, paypal_ids[0], context=context)
return dict.fromkeys(ids, paypal.paypal_email_account)
return dict.fromkeys(ids, False)
def _set_paypal_account(self, cr, uid, id, name, value, arg, context=None):
Acquirer = self.pool['payment.acquirer']
company_id = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.id
paypal_account = self.browse(cr, uid, id, context=context).paypal_account
paypal_ids = Acquirer.search(cr, uid, [
('website_published', '=', True),
('paypal_email_account', '=', paypal_account),
('company_id', '=', company_id),
], context=context)
if paypal_ids:
Acquirer.write(cr, uid, paypal_ids, {'paypal_email_account': value}, context=context)
return True
_columns = {
'paypal_account': fields.function(
_get_paypal_account,
fnct_inv=_set_paypal_account,
nodrop=True,
type='char', string='Paypal Account',
help="Paypal username (usually email) for receiving online payments."
),
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment