mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2026-10-25 15:30:05 -05:00
[PATCH] Upstream patch - 27092022
This commit is contained in:
1 parent
a1b0ef4302
commit
475b3014fe
6 files changed
+82
-6
No files matched your search
@@ -652,7 +652,7 @@ class TestAccountReconciliationCommon(AccountTestInvoicingCommon):
|
||||
if currency_id:
|
||||
invoice_vals['currency_id'] = currency_id
|
||||
|
||||
invoice = self.env['account.move'].with_context(default_move_type=type).create(invoice_vals)
|
||||
invoice = self.env['account.move'].with_context(default_move_type=move_type).create(invoice_vals)
|
||||
if auto_validate:
|
||||
invoice.action_post()
|
||||
return invoice
|
||||
|
||||
@@ -20,7 +20,8 @@ var EventRegistrationForm = Widget.extend({
|
||||
.off('click')
|
||||
.click(function (ev) {
|
||||
self.on_click(ev);
|
||||
});
|
||||
})
|
||||
.prop('disabled', false);
|
||||
});
|
||||
return res;
|
||||
},
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 pt-3 pt-lg-0 pl-2 pl-lg-0">
|
||||
<button type="submit" class="btn btn-primary o_wait_lazy_js btn-block a-submit" t-attf-id="#{event.id}">
|
||||
<button type="submit" class="btn btn-primary o_wait_lazy_js btn-block a-submit" t-attf-id="#{event.id}" disabled="disabled">
|
||||
Register
|
||||
<t t-if="event.seats_limited and event.seats_max and event.seats_available <= (event.seats_max * 0.2)">
|
||||
(only <t t-esc="event.seats_available"/> available)
|
||||
|
||||
@@ -10,7 +10,7 @@ class SaleOrder(models.Model):
|
||||
|
||||
def _cart_find_product_line(self, product_id=None, line_id=None, **kwargs):
|
||||
self.ensure_one()
|
||||
lines = super(SaleOrder, self)._cart_find_product_line(product_id, line_id)
|
||||
lines = super(SaleOrder, self)._cart_find_product_line(product_id, line_id, **kwargs)
|
||||
if line_id:
|
||||
return lines
|
||||
domain = [('id', 'in', lines.ids)]
|
||||
|
||||
@@ -80,7 +80,7 @@ class SaleOrder(models.Model):
|
||||
product = self.env['product.product'].browse(product_id)
|
||||
|
||||
# split lines with the same product if it has untracked attributes
|
||||
if product and (product.product_tmpl_id.has_dynamic_attributes() or product.product_tmpl_id._has_no_variant_attributes()) and not line_id:
|
||||
if product and (product.product_tmpl_id.has_dynamic_attributes() or product.product_tmpl_id._has_no_variant_attributes()) and not line_id and not kwargs.get('force_search', False):
|
||||
return self.env['sale.order.line']
|
||||
|
||||
domain = [('order_id', '=', self.id), ('product_id', '=', product_id)]
|
||||
@@ -132,7 +132,7 @@ class SaleOrder(models.Model):
|
||||
else:
|
||||
pu = product.price
|
||||
if order.pricelist_id and order.partner_id:
|
||||
order_line = order._cart_find_product_line(product.id)
|
||||
order_line = order._cart_find_product_line(product.id, force_search=True)
|
||||
if order_line:
|
||||
pu = self.env['account.tax']._fix_tax_included_price_company(pu, product.taxes_id, order_line[0].tax_id, self.company_id)
|
||||
|
||||
|
||||
@@ -205,3 +205,78 @@ class TestWebsiteSaleProductPricelist(TestSaleProductAttributeValueCommon, TestW
|
||||
with MockRequest(self.env, website=current_website, sale_order_id=so.id):
|
||||
so._cart_update(product_id=test_product.product_variant_id.id, line_id=sol.id, set_qty=1)
|
||||
self.assertEqual(round(sol.price_total), 50, "100$ with 50% discount + 0% tax (mapped from fp 10% -> 0%)")
|
||||
|
||||
def test_cart_update_with_fpos_no_variant_product(self):
|
||||
# We will test that the mapping of an 10% included tax by a 0% by a fiscal position is taken into account when updating the cart for no_variant product
|
||||
self.env.user.partner_id.country_id = False
|
||||
current_website = self.env['website'].get_current_website()
|
||||
pricelist = current_website.get_current_pricelist()
|
||||
(self.env['product.pricelist'].search([]) - pricelist).write({'active': False})
|
||||
# Add 10% tax on product
|
||||
tax10 = self.env['account.tax'].create({'name': "Test tax 10", 'amount': 10, 'price_include': True, 'amount_type': 'percent', 'type_tax_use': 'sale'})
|
||||
tax0 = self.env['account.tax'].create({'name': "Test tax 0", 'amount': 0, 'price_include': True, 'amount_type': 'percent', 'type_tax_use': 'sale'})
|
||||
|
||||
# Create fiscal position mapping taxes 10% -> 0%
|
||||
fpos = self.env['account.fiscal.position'].create({
|
||||
'name': 'test',
|
||||
})
|
||||
self.env['account.fiscal.position.tax'].create({
|
||||
'position_id': fpos.id,
|
||||
'tax_src_id': tax10.id,
|
||||
'tax_dest_id': tax0.id,
|
||||
})
|
||||
|
||||
product = self.env['product.product'].create({
|
||||
'name': 'prod_no_variant',
|
||||
'list_price': 110,
|
||||
'taxes_id': [(6, 0, [tax10.id])],
|
||||
'type': 'consu',
|
||||
})
|
||||
|
||||
# create an attribute with one variant
|
||||
product_attribute = self.env['product.attribute'].create({
|
||||
'name': 'test_attr',
|
||||
'display_type': 'radio',
|
||||
'create_variant': 'no_variant',
|
||||
})
|
||||
|
||||
# create attribute value
|
||||
a1 = self.env['product.attribute.value'].create({
|
||||
'name': 'pa_value',
|
||||
'attribute_id': product_attribute.id,
|
||||
'sequence': 1,
|
||||
})
|
||||
|
||||
# set variant value to product template
|
||||
product_template = self.env['product.template'].search(
|
||||
[('name', '=', 'prod_no_variant')], limit=1)
|
||||
|
||||
product_template.attribute_line_ids = [(0, 0, {
|
||||
'attribute_id': product_attribute.id,
|
||||
'value_ids': [(6, 0, [a1.id])],
|
||||
})]
|
||||
|
||||
# publish the product on website
|
||||
product_template.is_published = True
|
||||
|
||||
# create a so for user using the fiscal position
|
||||
|
||||
so = self.env['sale.order'].create({
|
||||
'partner_id': self.env.user.partner_id.id,
|
||||
})
|
||||
sol = self.env['sale.order.line'].create({
|
||||
'name': product_template.name,
|
||||
'product_id': product.id,
|
||||
'product_uom_qty': 1,
|
||||
'product_uom': product_template.uom_id.id,
|
||||
'price_unit': product_template.list_price,
|
||||
'order_id': so.id,
|
||||
'tax_id': [(6, 0, [tax10.id])],
|
||||
})
|
||||
self.assertEqual(round(sol.price_total), 110.0, "110$ with 10% included tax")
|
||||
so.pricelist_id = pricelist
|
||||
so.fiscal_position_id = fpos
|
||||
sol.product_id_change()
|
||||
with MockRequest(self.env, website=current_website, sale_order_id=so.id):
|
||||
so._cart_update(product_id=product.id, line_id=sol.id, set_qty=1)
|
||||
self.assertEqual(round(sol.price_total), 100, "100$ with public price+ 0% tax (mapped from fp 10% -> 0%)")
|
||||
Reference in new issue
Block a user