Files
odoo_source/addons/product_matrix/tests/common.py
T
Xavier Morel 618562802e [IMP] [sale_]product_matrix: remove t-raw
Using `sale_product_matrix`'s tour as `product_matrix` doesn't
actually have any test for this.

Remove t-raw from the product_matrix(.extra_price) template, by moving
the formatting to the client side (unclear why it was done by the
server in the first place).

Also fixes a bug where a negative price_extra would have *two* `-`
signs: one before the currency, and one after the currency: the price
being formatted should be abs'd to avoid a negation being generated by
the monetary formatting. Also uses non-breaking spaces everywhere
where the server-side formatting mixed breaking and non-breaking
spaces. Keeps from the original the peculiarity that the extra price
should always have a sign positioned before prefix currency signs.

Also changes the calling conventions of `product_matrix.extra_price`:
instead of being called with a formatted `price` it's now called with
the entire cell object.
2021-07-20 05:41:36 +00:00

52 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import tagged, common
@tagged('post_install', '-at_install')
class TestMatrixCommon(common.HttpCase):
def setUp(self):
super(TestMatrixCommon, self).setUp()
# Prepare relevant test data
# This is not included in demo data to avoid useless noise
product_attributes = self.env['product.attribute'].create([{
'name': 'PA1',
'create_variant': 'always',
'sequence': 1
}, {
'name': 'PA2',
'create_variant': 'always',
'sequence': 2
}, {
'name': 'PA3',
'create_variant': 'dynamic',
'sequence': 3
}, {
'name': 'PA4',
'create_variant': 'no_variant',
'sequence': 4
}])
self.env['product.attribute.value'].create([{
'name': 'PAV' + str(product_attribute.sequence) + str(i),
'attribute_id': product_attribute.id
} for i in range(1, 3) for product_attribute in product_attributes])
self.matrix_template = self.env['product.template'].create({
'name': "Matrix",
'type': "consu",
'uom_id': self.ref("uom.product_uom_unit"),
'uom_po_id': self.ref("uom.product_uom_unit"),
'attribute_line_ids': [(0, 0, {
'attribute_id': attribute.id,
'value_ids': [(6, 0, attribute.value_ids.ids)]
}) for attribute in product_attributes],
})
def get_ptav(pav_name):
return self.env['product.template.attribute.value']\
.search([('product_attribute_value_id.name', '=', pav_name)])
get_ptav('PAV12').price_extra = 50
get_ptav('PAV31').price_extra = -25