[FIX] point_of_sale: add one default cash payment method
Before this commit: if more than one cash payment methods exist, it would add all of them by default when you create a point of sale. This commit prevents adding more than one cash payment method: https://github.com/odoo/odoo/commit/f9da3590261b304f9c12f01f5800cec50faebc1a So it's impossible to create a new point of sale when there are more than one cash payment methods. The solution is to limit the default cash payment methods to one. opw-3134418 closes odoo/odoo#110717 X-original-commit: 5c839e684261e60328c7e06ae09685734507bf4f Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
This commit is contained in:
@@ -28,13 +28,17 @@ class PosConfig(models.Model):
|
||||
def _default_payment_methods(self):
|
||||
""" Should only default to payment methods that are compatible to this config's company and currency.
|
||||
"""
|
||||
return self.env['pos.payment.method'].search([
|
||||
domain = [
|
||||
('split_transactions', '=', False),
|
||||
('company_id', '=', self.env.company.id),
|
||||
'|',
|
||||
('journal_id', '=', False),
|
||||
('journal_id.currency_id', 'in', (False, self.env.company.currency_id.id)),
|
||||
])
|
||||
]
|
||||
non_cash_pm = self.env['pos.payment.method'].search(domain + [('is_cash_count', '=', False)])
|
||||
available_cash_pm = self.env['pos.payment.method'].search(domain + [('is_cash_count', '=', True),
|
||||
('config_ids', '=', False)], limit=1)
|
||||
return non_cash_pm | available_cash_pm
|
||||
|
||||
def _get_group_pos_manager(self):
|
||||
return self.env.ref('point_of_sale.group_pos_manager')
|
||||
|
||||
@@ -10,12 +10,33 @@ class TestFrontend(odoo.tests.HttpCase):
|
||||
self.env = self.env(user=self.env.ref('base.user_admin'))
|
||||
account_obj = self.env['account.account']
|
||||
|
||||
account_receivable = account_obj.create({'code': 'X1012',
|
||||
'name': 'Account Receivable - Test',
|
||||
'account_type': 'asset_receivable',
|
||||
'reconcile': True})
|
||||
|
||||
printer = self.env['restaurant.printer'].create({
|
||||
'name': 'Kitchen Printer',
|
||||
'proxy_ip': 'localhost',
|
||||
})
|
||||
drinks_category = self.env['pos.category'].create({'name': 'Drinks'})
|
||||
|
||||
main_company = self.env.ref('base.main_company')
|
||||
|
||||
second_cash_journal = self.env['account.journal'].create({
|
||||
'name': 'Cash 2',
|
||||
'code': 'CSH2',
|
||||
'type': 'cash',
|
||||
'company_id': main_company.id
|
||||
})
|
||||
|
||||
self.env['pos.payment.method'].create({
|
||||
'name': 'Cash 2',
|
||||
'split_transactions': False,
|
||||
'receivable_account_id': account_receivable.id,
|
||||
'journal_id': second_cash_journal.id,
|
||||
})
|
||||
|
||||
pos_config = self.env['pos.config'].create({
|
||||
'name': 'Bar',
|
||||
'module_pos_restaurant': True,
|
||||
@@ -77,13 +98,6 @@ class TestFrontend(odoo.tests.HttpCase):
|
||||
'position_v': 250,
|
||||
})
|
||||
|
||||
main_company = self.env.ref('base.main_company')
|
||||
|
||||
account_receivable = account_obj.create({'code': 'X1012',
|
||||
'name': 'Account Receivable - Test',
|
||||
'account_type': 'asset_receivable',
|
||||
'reconcile': True})
|
||||
|
||||
self.env['ir.property']._set_default(
|
||||
'property_account_receivable_id',
|
||||
'res.partner',
|
||||
|
||||
Reference in New Issue
Block a user