[FIX] point_of_sale: access error when limited partners
Steps to reproduce: 1. pos.config is in company1 2. create a partner with company = company2 3. change pos.config to limited partners loading 4. open the pos ui (to call load_pos_data) old behavior: access error closes odoo/odoo#89013 Now: method is called without error X-original-commit: eade911354dac775b3b96212698dbb7e2d644390 Signed-off-by: Masereel Pierre <pim@odoo.com>
This commit is contained in:
@@ -729,8 +729,11 @@ class PosConfig(models.Model):
|
||||
LEFT JOIN pm
|
||||
ON (
|
||||
partner.id = pm.partner_id)
|
||||
WHERE (
|
||||
partner.company_id=%s OR partner.company_id IS NULL
|
||||
)
|
||||
ORDER BY COALESCE(pm.order_count, 0) DESC,
|
||||
NAME limit %s;
|
||||
""", [str(self.limited_partners_amount)])
|
||||
""", [self.company_id.id, str(self.limited_partners_amount)])
|
||||
result = self.env.cr.fetchall()
|
||||
return result
|
||||
|
||||
@@ -807,3 +807,25 @@ class TestPoSBasicConfig(TestPoSCommon):
|
||||
|
||||
open_and_check(pos01_data)
|
||||
open_and_check(pos02_data)
|
||||
|
||||
def test_load_pos_data_should_not_fail(self):
|
||||
"""load_pos_data shouldn't fail
|
||||
|
||||
(Include test conditions here if possible)
|
||||
|
||||
- When there are partners that belong to different company
|
||||
"""
|
||||
|
||||
# create a partner that belongs to different company
|
||||
company2 = self.company_data_2['company']
|
||||
self.env['res.partner'].create({
|
||||
'name': 'Test',
|
||||
'company_id': company2.id,
|
||||
})
|
||||
|
||||
# activate limited partners loading
|
||||
self.config.limited_partners_loading = True
|
||||
self.open_new_session()
|
||||
|
||||
# calling load_pos_data should not raise an error
|
||||
self.pos_session.load_pos_data()
|
||||
|
||||
Reference in New Issue
Block a user