[PATCH] Upstream patch - 12042022

This commit is contained in:
Parthiv Patel
2022-04-12 08:36:11 +00:00
parent 767eb218db
commit 0ecb9bbc8a
10 changed files with 189 additions and 15 deletions

View File

@@ -50,7 +50,7 @@
</div>
<div class="swissqr_text content">
<span t-field="o.partner_bank_id.acc_number"/><br/>
<span t-field="o.company_id.name"/><br/>
<span t-esc="o.partner_bank_id.acc_holder_name or o.company_id.name"/><br/>
<span t-field="o.company_id.street"/><br/>
<span t-field="o.company_id.country_id.code"/>
<span t-field="o.company_id.zip"/>
@@ -152,7 +152,7 @@
</div>
<div class="swissqr_text content">
<span t-field="o.partner_bank_id.acc_number"/><br/>
<span t-field="o.company_id.name"/><br/>
<span t-esc="o.partner_bank_id.acc_holder_name or o.company_id.name"/><br/>
<span t-field="o.company_id.street"/><br/>
<span t-field="o.company_id.country_id.code"/>
<span t-field="o.company_id.zip"/>

View File

@@ -268,7 +268,7 @@
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('cuenta216_10'),
'account_id': ref('cuenta216_10_20'),
}),
]"/>
</record>
@@ -308,7 +308,7 @@
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('cuenta216_10'),
'account_id': ref('cuenta216_10_20'),
}),
]"/>
</record>
@@ -335,6 +335,7 @@
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('cuenta118_01'),
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
@@ -347,6 +348,7 @@
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('cuenta118_01'),
}),
]"/>
</record>
@@ -386,7 +388,7 @@
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('cuenta119_01'),
'account_id': ref('cuenta118_01'),
}),
]"/>
</record>
@@ -426,7 +428,7 @@
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('cuenta119_01'),
'account_id': ref('cuenta118_01'),
}),
]"/>
</record>
@@ -467,7 +469,7 @@
'factor_percent': 100,
'repartition_type': 'tax',
'tag_ids': [ref('l10n_mx.tag_iva')],
'account_id': ref('cuenta209_01'),
'account_id': ref('cuenta208_01'),
'tag_ids': [ref('tag_iva')],
}),
]"/>

View File

@@ -172,14 +172,14 @@
<field name="name">Podatek - Do przeniesienia</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="3"/>
<field name="formula">PLTAXC_04_16 + PLTAXC_05_18 + PLTAXC_06_20 + PLTAXC_09_24 + PLTAXC_10_26 + PLTAXC_11_28 + PLTAXC_12_32 + PLTAXD_02_42</field>
<field name="formula">PLTAXC - PLTAXD</field>
</record>
<record id="account_tax_report_line_nad_naleznym" model="account.tax.report.line">
<field name="name">Podatek - Nadwyżka naliczonego nad należnym</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="1"/>
<field name="formula">PLTAXC_04_16 + PLTAXC_05_18 + PLTAXC_06_20 + PLTAXC_09_24 + PLTAXC_10_26 + PLTAXC_11_28 + PLTAXC_12_32 + PLTAXD_02_42</field>
<field name="formula">PLTAXC - PLTAXD</field>
<field name="parent_id" ref="account_tax_report_line_do_przeniesienia"/>
</record>
@@ -187,7 +187,7 @@
<field name="name">Podatek - Do wpłaty do US</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="1"/>
<field name="formula">PLTAXC_04_16 + PLTAXC_05_18 + PLTAXC_06_20 + PLTAXC_09_24 + PLTAXC_10_26 + PLTAXC_11_28 + PLTAXC_12_32 + PLTAXD_02_42</field>
<field name="formula">PLTAXC - PLTAXD</field>
<field name="parent_id" ref="account_tax_report_line_nad_naleznym"/>
</record>
@@ -207,6 +207,7 @@
<record id="account_tax_report_line_podatek_razem_c" model="account.tax.report.line">
<field name="name">Podatek - Razem C</field>
<field name="code">PLTAXC</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="3"/>
<field name="formula">PLTAXC_04_16 + PLTAXC_05_18 + PLTAXC_06_20 + PLTAXC_09_24 + PLTAXC_10_26 + PLTAXC_11_28 + PLTAXC_12_32</field>
@@ -301,6 +302,7 @@
<record id="account_tax_report_line_podatek_razem_d" model="account.tax.report.line">
<field name="name">Podatek - Razem D</field>
<field name="code">PLTAXD</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="4"/>
<field name="parent_id" ref="account_tax_report_line_do_US"/>

View File

@@ -2416,6 +2416,122 @@ QUnit.test('chat window should remain folded when new message is received', asyn
);
});
QUnit.test('chat window scroll position should remain the same after switching left', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 20,
is_minimized: true,
state: 'open',
});
this.data['mail.channel'].records.push({
id: 21,
is_minimized: true,
state: 'open',
});
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
body: "not empty",
channel_ids: [20],
});
}
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
body: "not empty",
channel_ids: [21],
});
}
await this.start();
const thread1LocalId = this.env.models['mail.thread'].findFromIdentifyingData({
id: 20,
model: 'mail.channel',
}).localId;
const thread2LocalId = this.env.models['mail.thread'].findFromIdentifyingData({
id: 21,
model: 'mail.channel',
}).localId;
document.querySelector(`.o_ChatWindow[data-thread-local-id="${thread1LocalId}"] .o_ThreadView_messageList`).scrollTop = 100;
document.querySelector(`.o_ChatWindow[data-thread-local-id="${thread2LocalId}"] .o_ThreadView_messageList`).scrollTop = 110;
await this.afterEvent({
eventName: 'o-thread-view-hint-processed',
func: () => document.querySelector('.o_ChatWindowHeader_commandShiftLeft').click(),
message: "Should wait until the scroll is adjusted after a command shift.",
predicate: ({ hint }) => {
return hint.type === 'adjust-scroll';
},
});
assert.strictEqual(
document.querySelector(`.o_ChatWindow[data-thread-local-id="${thread2LocalId}"] .o_ThreadView_messageList`).scrollTop,
110,
"Scroll position should remain the same after a chat window shift"
);
assert.strictEqual(
document.querySelector(`.o_ChatWindow[data-thread-local-id="${thread1LocalId}"] .o_ThreadView_messageList`).scrollTop,
100,
"Scroll position should remain the same after a chat window shift"
);
});
QUnit.test('chat window scroll position should remain the same after switching right', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 20,
is_minimized: true,
state: 'open',
});
this.data['mail.channel'].records.push({
id: 21,
is_minimized: true,
state: 'open',
});
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
body: "not empty",
channel_ids: [20],
});
}
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
body: "not empty",
channel_ids: [21],
});
}
await this.start();
const thread1LocalId = this.env.models['mail.thread'].findFromIdentifyingData({
id: 20,
model: 'mail.channel',
}).localId;
const thread2LocalId = this.env.models['mail.thread'].findFromIdentifyingData({
id: 21,
model: 'mail.channel',
}).localId;
document.querySelector(`.o_ChatWindow[data-thread-local-id="${thread1LocalId}"] .o_ThreadView_messageList`).scrollTop = 100;
document.querySelector(`.o_ChatWindow[data-thread-local-id="${thread2LocalId}"] .o_ThreadView_messageList`).scrollTop = 110;
await this.afterEvent({
eventName: 'o-thread-view-hint-processed',
func: () => document.querySelector('.o_ChatWindowHeader_commandShiftRight').click(),
message: "Should wait until the scroll is adjusted after a command shift.",
predicate: ({ hint }) => {
return hint.type === 'adjust-scroll';
},
});
assert.strictEqual(
document.querySelector(`.o_ChatWindow[data-thread-local-id="${thread2LocalId}"] .o_ThreadView_messageList`).scrollTop,
110,
"Scroll position should remain the same after a chat window shift"
);
assert.strictEqual(
document.querySelector(`.o_ChatWindow[data-thread-local-id="${thread1LocalId}"] .o_ThreadView_messageList`).scrollTop,
100,
"Scroll position should remain the same after a chat window shift"
);
});
});
});
});

View File

@@ -143,6 +143,7 @@ class MessageList extends Component {
case 'change-of-thread-cache':
case 'home-menu-hidden':
case 'home-menu-shown':
case 'adjust-scroll':
// thread just became visible, the goal is to restore its
// saved position if it exists or scroll to the end
this._adjustScrollFromModel();

View File

@@ -161,6 +161,11 @@ function factory(dependencies) {
_newOrdered[index + 1] = chatWindow.localId;
this.update({ _ordered: _newOrdered });
chatWindow.focus();
for (const loopedChatWindow of [chatWindow, otherChatWindow]) {
if (loopedChatWindow.threadView) {
loopedChatWindow.threadView.addComponentHint('adjust-scroll');
}
}
}
/**
@@ -181,6 +186,11 @@ function factory(dependencies) {
_newOrdered[index - 1] = chatWindow.localId;
this.update({ _ordered: _newOrdered });
chatWindow.focus();
for (const loopedChatWindow of [chatWindow, otherChatWindow]) {
if (loopedChatWindow.threadView) {
loopedChatWindow.threadView.addComponentHint('adjust-scroll');
}
}
}
/**
@@ -198,6 +208,11 @@ function factory(dependencies) {
_newOrdered[index1] = chatWindow2.localId;
_newOrdered[index2] = chatWindow1.localId;
this.update({ _ordered: _newOrdered });
for (const chatWindow of [chatWindow1, chatWindow2]) {
if (chatWindow.threadView) {
chatWindow.threadView.addComponentHint('adjust-scroll');
}
}
}
//----------------------------------------------------------------------

View File

@@ -159,8 +159,8 @@ class ProductProduct(models.Model):
continue
rounding = component.uom_id.rounding
component_res = (
res.get(component.id)
if component.id in res
qties.get(component.id)
if component.id in qties
else {
"virtual_available": float_round(component.virtual_available, precision_rounding=rounding),
"qty_available": float_round(component.qty_available, precision_rounding=rounding),

View File

@@ -86,7 +86,8 @@ class ProductPricelist(models.Model):
def _check_website_pricelist(self):
for website in self.env['website'].search([]):
if not website.pricelist_ids:
# sudo() to be able to read pricelists/website from another company
if not website.sudo().pricelist_ids:
raise UserError(_("With this action, '%s' website would not have any pricelist available.") % (website.name))
def _is_available_on_website(self, website_id):

View File

@@ -502,13 +502,24 @@ class TestWebsitePriceListMultiCompany(TransactionCaseWithUserDemo):
self.company2 = self.env['res.company'].create({'name': 'Test Company'})
self.demo_user.company_ids += self.company2
# Set company2 as current company for demo user
Website = self.env['website']
self.website = self.env.ref('website.default_website')
self.website.company_id = self.company2
# Delete unused website, it will make PL manipulation easier, avoiding
# UserError being thrown when a website wouldn't have any PL left.
Website.search([('id', '!=', self.website.id)]).unlink()
self.website2 = Website.create({
'name': 'Website 2',
'company_id': self.company1.id,
})
# Create a company pricelist for each company and set it to demo user
self.c1_pl = self.env['product.pricelist'].create({
'name': 'Company 1 Pricelist',
'company_id': self.company1.id,
# The `website_id` field will default to the company's website,
# in this case `self.website2`.
})
self.c2_pl = self.env['product.pricelist'].create({
'name': 'Company 2 Pricelist',
@@ -524,7 +535,6 @@ class TestWebsitePriceListMultiCompany(TransactionCaseWithUserDemo):
irp1 = self.env['ir.property'].with_company(self.company1)._get("property_product_pricelist", "res.partner", self.demo_user.partner_id.id)
irp2 = self.env['ir.property'].with_company(self.company2)._get("property_product_pricelist", "res.partner", self.demo_user.partner_id.id)
self.assertEqual((irp1, irp2), (self.c1_pl, self.c2_pl), "Ensure there is an `ir.property` for demo partner for every company, and that the pricelist is the company specific one.")
simulate_frontend_context(self)
# ---------------------------------- IR.PROPERTY -------------------------------------
# id | name | res_id | company_id | value_reference
# ------------------------------------------------------------------------------------
@@ -544,6 +554,8 @@ class TestWebsitePriceListMultiCompany(TransactionCaseWithUserDemo):
for the company1 as we should get the website's company pricelist
and not the demo user's current company pricelist.
'''
simulate_frontend_context(self, self.website.id)
# First check: It should return ir.property,4 as company_id is
# website.company_id and not env.user.company_id
company_id = self.website.company_id.id
@@ -556,3 +568,28 @@ class TestWebsitePriceListMultiCompany(TransactionCaseWithUserDemo):
# also read a pricelist from another company if that company is the one
# from the currently visited website.
self.env(user=self.user_demo)['product.pricelist'].browse(demo_pl.id).name
def test_archive_pricelist_1(self):
''' Test that when a pricelist is archived, the check that verify that
all website have at least one pricelist have access to all
pricelists (considering all companies).
'''
self.c2_pl.website_id = self.website
c2_pl2 = self.c2_pl.copy({'name': 'Copy of c2_pl'})
self.env['product.pricelist'].search([
('id', 'not in', (self.c2_pl + self.c1_pl + c2_pl2).ids)
]).write({'active': False})
# ---------------- PRICELISTS ----------------
# name | website_id | company_id |
# --------------------------------------------
# self.c1_pl | self.website2 | self.company1 |
# self.c2_pl | self.website | self.company2 |
# c2_pl2 | self.website | self.company2 |
self.demo_user.groups_id += self.env.ref('sales_team.group_sale_manager')
# The test is here: while having access only to self.company2 records,
# archive should not raise an error
self.c2_pl.with_user(self.demo_user).with_context(allowed_company_ids=self.company2.ids).write({'active': False})

View File

@@ -14,7 +14,7 @@ class Http(models.AbstractModel):
obj = None
if xmlid:
obj = self._xmlid_to_obj(self.env, xmlid)
if obj._name != 'slide.slide':
if obj and obj._name != 'slide.slide':
obj = None
elif id and model == 'slide.slide':
obj = self.env[model].browse(int(id))