[MERGE] forward port branch saas-11.3 up to 2d824a5b7a

This commit is contained in:
Christophe Simonis
2019-01-08 17:08:48 +01:00
15 changed files with 1582 additions and 1559 deletions
+2 -2
View File
@@ -1498,7 +1498,7 @@ class AccountPartialReconcile(models.Model):
'analytic_account_id': line.analytic_account_id.id,
'analytic_tag_ids': line.analytic_tag_ids.ids,
'tax_exigible': True,
'amount_currency': self.amount_currency and line.currency_id.round(-line.amount_currency * amount / line.balance) or 0.0,
'amount_currency': line.amount_currency and line.currency_id.round(-line.amount_currency * amount / line.balance) or 0.0,
'currency_id': line.currency_id.id,
'move_id': newly_created_move.id,
'partner_id': line.partner_id.id,
@@ -1513,7 +1513,7 @@ class AccountPartialReconcile(models.Model):
'analytic_tag_ids': line.analytic_tag_ids.ids,
'tax_line_id': line.tax_line_id.id,
'tax_exigible': True,
'amount_currency': self.amount_currency and line.currency_id.round(line.amount_currency * amount / line.balance) or 0.0,
'amount_currency': line.amount_currency and line.currency_id.round(line.amount_currency * amount / line.balance) or 0.0,
'currency_id': line.currency_id.id,
'move_id': newly_created_move.id,
'partner_id': line.partner_id.id,
+1 -1
View File
@@ -286,7 +286,7 @@
<field name="name">hr.holidays.view.tree</field>
<field name="model">hr.leave</field>
<field name="arch" type="xml">
<tree decoration-danger="state == 'refuse'" decoration-info="state == ' draft'" string="Leave Requests"
<tree decoration-danger="state == 'refuse'" decoration-info="state == 'draft'" string="Leave Requests"
decoration-bf="message_needaction == True">
<field name="employee_id"/>
<field name="holiday_type" string="Mode" groups="base.group_no_one"/>
File diff suppressed because it is too large Load Diff
@@ -61,7 +61,7 @@ result = contract.wage_with_holidays
<field name="parent_id" ref="hr_payroll.ALW"/>
</record>
<record id="hr_payroll_head_pp" model="hr.salary.rule.category">
<field name="name">Withholding Tax Grid 2018 (Precompte Professionnel Bareme 2018)</field>
<field name="name">Withholding Tax Grid 2019 (Precompte Professionnel Bareme 2019)</field>
<field name="code">PP</field>
<field name="parent_id" ref="hr_payroll.DED"/>
</record>
@@ -80,11 +80,6 @@ result = contract.wage_with_holidays
<field name="code">FamRed</field>
<field name="parent_id" ref="hr_payroll.DED"/>
</record>
<record id="hr_salary_rule_pp_reductions" model="hr.salary.rule.category">
<field name="name">Withholding Tax Reduction</field>
<field name="code">PPRed</field>
<field name="parent_id" ref="hr_payroll.DED"/>
</record>
<record id="hr_salary_rule_category_spec_soc_contribution" model="hr.salary.rule.category">
<field name="name">Special social contribution</field>
<field name="code">SSC</field>
@@ -144,14 +139,14 @@ if contract.mobile:
<field name="code">EmpBonus.1</field>
<field name="sequence">42</field>
<field name="condition_select">python</field>
<field name="condition_python">result = categories.BRUT &lt;= 2510.47</field>
<field name="condition_python">result = categories.BRUT &lt;= 2560.57</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
salary = categories.BRUT
if salary &lt;= 1609.47:
result = 197.67
elif salary &lt;= 2510.47:
result = 197.67 - (0.2194 * (salary - 1609.47))
if salary &lt;= 1641.62:
result = 201.62
elif salary &lt;= 2560.57:
result = 201.62 - (0.2194 * (salary - 1641.62))
</field>
</record>
<record id="hr_salary_rule_employment_bonus_workers" model="hr.salary.rule">
@@ -160,14 +155,14 @@ elif salary &lt;= 2510.47:
<field name="code">EmpBonus.2</field>
<field name="sequence">42</field>
<field name="condition_select">python</field>
<field name="condition_python">result = categories.BRUT + categories.ONSS &lt;= 2510.47</field>
<field name="condition_python">result = categories.BRUT + categories.ONSS &lt;= 2560.57</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
salary = categories.BRUT
if salary &lt;= 1609.47:
result = 213.48
elif salary &lt;= 2510.47:
result = 213.48 - (0.2369 * (salary - 1609.47))
if salary &lt;= 1641.62:
result = 217.75
elif salary &lt;= 2560.57:
result = 217.75 - (0.2370 * (salary - 1641.62))
</field>
</record>
@@ -275,40 +270,6 @@ else:
<field name="condition_python">result = employee.resident_bool==True</field>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_salary_rule_pp_reduction_employees" model="hr.salary.rule">
<field name="category_id" ref="hr_salary_rule_pp_reductions"/>
<field name="name">Withholding Tax Reduction for Low Salaries (ONSS)</field>
<field name="code">PPRed.1</field>
<field name="sequence">132</field>
<field name="condition_select">python</field>
<field name="condition_python">result = categories.BRUT &lt;= 2431.27</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
salary = categories.BRUT
percentage = 0.2803
if salary &lt;= 1577.89:
result = 193.79 * percentage
elif salary &lt;= 2461.27:
result = (193.79 - (0.2194 * (salary - 1577.89))) * percentage
</field>
</record>
<record id="hr_salary_rule_pp_reduction_workers" model="hr.salary.rule">
<field name="category_id" ref="hr_salary_rule_pp_reductions"/>
<field name="name">Withholding Tax Reduction for Low Salaries (ONSS)</field>
<field name="code">PPRed.2</field>
<field name="sequence">133</field>
<field name="condition_select">python</field>
<field name="condition_python">result = categories.BRUT &lt;= 2431.27</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
salary = categories.BRUT
percentage = 0.2803
if salary &lt;= 1577.89:
result = 209.29 * percentage
elif salary &lt;= 2461.27:
result = (209.29 - (0.2369 * (salary - 1577.89))) * percentage
</field>
</record>
<record id="hr_payroll_rules_child_alw" model="hr.salary.rule">
<field name="category_id" ref="hr_payroll_head_child_alw"/>
<field name="name">Child Allowance Belgium</field>
@@ -316,7 +277,7 @@ elif salary &lt;= 2461.27:
<field name="sequence">140</field>
<field name="amount_select">fix</field>
<field name="condition_select">python</field>
<field name="condition_python">result = bool(employee.dependent_children) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = bool(employee.dependent_children) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
</record>
<record id="hr_payroll_rules_child" model="hr.salary.rule">
<field name="category_id" ref="hr_payroll_head_child_alw"/>
@@ -333,7 +294,7 @@ elif salary &lt;= 2461.27:
a) Reduction for dependent children</field>
<field name="condition_select">python</field>
<field name="condition_python">result = bool(employee.dependent_children) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = bool(employee.dependent_children) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
</record>
<record id="hr_salary_rule_other_family_charges_reductions" model="hr.salary.rule">
<field name="category_id" ref="hr_salary_rule_category_family_reductions"/>
@@ -351,9 +312,9 @@ elif salary &lt;= 2461.27:
<field name="code">Red.Iso</field>
<field name="sequence">144</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (employee.marital in ['divorced', 'single', 'widower']) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = (employee.marital in ['divorced', 'single', 'widower']) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = min(25.00, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))</field>
<field name="amount_python_compute">result = min(26.00, - (categories.PP + categories.FamRed + categories.ChA))</field>
</record>
<record id="hr_salary_rule_reduction_isolated_parent" model="hr.salary.rule">
<field name="category_id" ref='hr_salary_rule_category_family_reductions'/>
@@ -362,9 +323,9 @@ elif salary &lt;= 2461.27:
<field name="code">Red.Iso.Par</field>
<field name="sequence">144</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (employee.marital == 'widower' or (employee.marital in ['divorced', 'single', 'widower'] and employee.dependent_children)) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = (employee.marital == 'widower' or (employee.marital in ['divorced', 'single', 'widower'] and employee.dependent_children)) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = min(36.00, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))</field>
<field name="amount_python_compute">result = min(36.00, - (categories.PP + categories.FamRed + categories.ChA))</field>
</record>
<record id="hr_salary_rule_reduction_disabled" model="hr.salary.rule">
<field name="category_id" ref='hr_salary_rule_category_family_reductions'/>
@@ -373,9 +334,9 @@ elif salary &lt;= 2461.27:
<field name="code">Red.Dis</field>
<field name="sequence">145</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (employee.disabled) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = (employee.disabled) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = min(36.00, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))</field>
<field name="amount_python_compute">result = min(36.00, - (categories.PP + categories.FamRed + categories.ChA))</field>
</record>
<record id="hr_salary_rule_reduction_seniors" model="hr.salary.rule">
<field name="category_id" ref='hr_salary_rule_category_family_reductions'/>
@@ -384,9 +345,9 @@ elif salary &lt;= 2461.27:
<field name="code">Red.Seniors</field>
<field name="sequence">146</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (employee.other_dependent_people and employee.dependent_seniors) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = (employee.other_dependent_people and employee.dependent_seniors) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = min(73.0 * employee.dependent_seniors, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))</field>
<field name="amount_python_compute">result = min(80.0 * employee.dependent_seniors, - (categories.PP + categories.FamRed + categories.ChA))</field>
</record>
<record id="hr_salary_rule_reduction_juniors" model="hr.salary.rule">
<field name="category_id" ref='hr_salary_rule_category_family_reductions'/>
@@ -395,9 +356,9 @@ elif salary &lt;= 2461.27:
<field name="code">Red.Juniors</field>
<field name="sequence">147</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (employee.other_dependent_people and employee.dependent_juniors) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = (employee.other_dependent_people and employee.dependent_juniors) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = min(36.0 * employee.dependent_juniors, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))</field>
<field name="amount_python_compute">result = min(36.0 * employee.dependent_juniors, - (categories.PP + categories.FamRed + categories.ChA))</field>
</record>
<record id="hr_salary_rule_reduction_insufficient_net" model="hr.salary.rule">
<field name="category_id" ref='hr_salary_rule_category_family_reductions'/>
@@ -406,9 +367,9 @@ elif salary &lt;= 2461.27:
<field name="code">Red.Spouse.Net</field>
<field name="sequence">148</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (employee.marital in ['married', 'cohabitant'] and employee.spouse_fiscal_status=='with income' and employee.spouse_net_revenue &lt;= 225.0) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = (employee.marital in ['married', 'cohabitant'] and employee.spouse_fiscal_status=='with income' and employee.spouse_net_revenue &lt;= 225.0) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = min(110.50, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))</field>
<field name="amount_python_compute">result = min(115.0, - (categories.PP + categories.FamRed + categories.ChA))</field>
</record>
<record id="hr_salary_rule_reduction_insufficient_other_net" model="hr.salary.rule">
<field name="category_id" ref='hr_salary_rule_category_family_reductions'/>
@@ -417,9 +378,9 @@ elif salary &lt;= 2461.27:
<field name="code">Red.Spouse.Oth.Net</field>
<field name="sequence">149</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (employee.marital in ['married', 'cohabitant'] and employee.spouse_fiscal_status=='with income' and not employee.spouse_net_revenue and employee.spouse_other_net_revenue &lt;= 450.0) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = (employee.marital in ['married', 'cohabitant'] and employee.spouse_fiscal_status=='with income' and not employee.spouse_net_revenue and employee.spouse_other_net_revenue &lt;= 450.0) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result = min(220.0, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))</field>
<field name="amount_python_compute">result = min(229.5, - (categories.PP + categories.FamRed + categories.ChA))</field>
</record>
<record id="hr_payroll_rules_spouse_handicap" model="hr.salary.rule">
<field name="category_id" ref="hr_payroll_head_div_net"/>
@@ -428,9 +389,9 @@ elif salary &lt;= 2461.27:
<field name="code">Sp.handicap</field>
<field name="sequence">150</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (employee.disabled_spouse_bool==True) and (categories.PP + categories.PPRed + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="condition_python">result = (employee.disabled_spouse_bool==True) and (categories.PP + categories.FamRed + categories.ChA &lt; 0.0)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">min(36.0, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))</field>
<field name="amount_python_compute">min(36.0, - (categories.PP + categories.FamRed + categories.ChA))</field>
</record>
<record id="hr_payroll_rules_parent_company_car" model="hr.salary.rule">
<field name="category_id" ref="hr_payroll_head_div_impos"/>
@@ -618,7 +579,6 @@ result = -min(ip_amount * tax_rate, 11745)
ref('hr_salary_rule_representation_fees'),
ref('hr_payroll_rules_suppl_net'),
ref('hr_payroll_rules_retained_net'),
ref('hr_salary_rule_pp_reduction_employees'),
ref('hr_salary_rule_ip'),
ref('hr_salary_rule_ip_deduction'),
ref('hr_salary_rule_ip_part'),
@@ -646,7 +606,6 @@ result = -min(ip_amount * tax_rate, 11745)
ref('hr_salary_rule_representation_fees'),
ref('hr_payroll_rules_suppl_net'),
ref('hr_payroll_rules_retained_net'),
ref('hr_salary_rule_pp_reduction_workers')
])]" name="rule_ids"/>
<field name="company_id" ref="base.main_company"/>
<field name="parent_id" ref="hr_payroll.structure_base"/>
+1 -1
View File
@@ -46,7 +46,7 @@ class MrpProductProduce(models.TransientModel):
product_uom_id = fields.Many2one('uom.uom', 'Unit of Measure')
lot_id = fields.Many2one('stock.production.lot', string='Lot/Serial Number')
produce_line_ids = fields.One2many('mrp.product.produce.line', 'product_produce_id', string='Product to Track')
product_tracking = fields.Selection(related="product_id.tracking", readonly=False)
product_tracking = fields.Selection(related="product_id.tracking", readonly=True)
@api.multi
def do_produce(self):
+4 -3
View File
@@ -661,9 +661,10 @@ class SaleOrder(models.Model):
self.force_quotation_send()
# create an analytic account if at least an expense product
if any([expense_policy != 'no' for expense_policy in self.order_line.mapped('product_id.expense_policy')]):
if not self.analytic_account_id:
self._create_analytic_account()
for order in self:
if any([expense_policy != 'no' for expense_policy in order.order_line.mapped('product_id.expense_policy')]):
if not order.analytic_account_id:
order._create_analytic_account()
return True
@@ -1862,7 +1862,7 @@ var BasicModel = AbstractModel.extend({
model: list.model,
method: 'read',
args: [_.pluck(data, 'id'), fieldNames],
context: record.context,
context: _.extend({}, record.context, field.context),
}).then(function (records) {
_.each(records, function (record) {
list_records[record.id].data = record;
@@ -2724,7 +2724,7 @@ var BasicModel = AbstractModel.extend({
var ids = record.data[fieldName] || [];
var list = self._makeDataPoint({
count: ids.length,
context: record.context,
context: _.extend({}, record.context, field.context),
fieldsInfo: fieldsInfo,
fields: view ? view.fields : fieldInfo.relatedFields,
limit: fieldInfo.limit,
@@ -11863,6 +11863,39 @@ QUnit.module('relational_fields', {
form.destroy();
});
QUnit.test('many2many read, field context is properly sent', function (assert) {
assert.expect(4);
this.data.partner.fields.timmy.context = {hello: 'world'};
this.data.partner.records[0].timmy = [12];
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form string="Partners">' +
'<field name="timmy" widget="many2many_tags"/>' +
'</form>',
res_id: 1,
mockRPC: function (route, args) {
if (args.method === 'read' && args.model === 'partner_type') {
assert.step(args.kwargs.context.hello);
}
return this._super.apply(this, arguments);
},
});
assert.verifySteps(['world']);
form.$buttons.find('.o_form_button_edit').click();
var $m2mInput = form.$('.o_field_many2manytags input');
$m2mInput.click();
$m2mInput.autocomplete('widget').find('li:first()').click();
assert.verifySteps(['world', 'world']);
form.destroy();
});
QUnit.module('FieldStatus');
QUnit.test('static statusbar widget on many2one field', function (assert) {
@@ -6,51 +6,27 @@
<a role="button" class="btn btn-danger d-none gengo_inprogress disabled" href="#"> <i class="fa fa-clock-o"></i> Translation in Progress</a>
<a role="button" class="btn btn-link gengo_info" data-action="translation_gengo_info">Count Words</a>
</t>
<t t-name="web_editor.TranslatorInfoDialog">
<div role="dialog" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<header class="modal-header">
<h2 class="modal-title">Translate this page</h2>
<button title="Close" aria-label="Close" type="button" class="close" data-dismiss="modal">×</button>
</header>
<main class="modal-body">
<section>
<p>You are about to enter the translation mode.</p>
<p>
Here are the visuals used to help you translate efficiently:
<ul class="oe_translate_examples">
<li style="background:#ffffb6;">
Content to translate or you can post them to <b><a href="http://gengo.com/" >Gengo</a></b> for translation.
</li>
<li data-oe-translation-state="inprogress">
Translation in process (Gengo)
</li>
<li data-oe-translation-state="translated">
Already translated content
</li>
</ul>
</p>
<p>
<t t-extend="web_editor.TranslatorInfoDialog">
<t t-jquery=".oe_translate_examples" t-operation="replace">
<ul class="oe_translate_examples">
<li style="background:#ffffb6;">
Content to translate or you can post them to <b><a href="http://gengo.com/" >Gengo</a></b> for translation.
</li>
<li data-oe-translation-state="inprogress">
Translation in process (Gengo)
</li>
<li data-oe-translation-state="translated">
Already translated content
</li>
</ul>
</t>
<t t-jquery="p:last" t-operation="replace">
<p> <!-- Keep wrong indent for translation -->
In this mode, you can translate texts or post texts to Gengo for translation.
To change the structure of the page, you must edit the
master page.
</p>
</section>
</main>
<footer class="modal-footer">
<div>
<input type="checkbox" name="do_not_show"/>
Do not show this dialog later.
</div>
<div>
<button type="button" data-action="activate" class="btn btn-primary">Ok</button>
<button type="button" class="btn btn-secondary" data-action="discard" data-dismiss="modal">Cancel</button>
</div>
</footer>
</div>
</div>
</div>
</p>
</t>
</t>
<t t-name="website.GengoTranslatorPostDialog">
+18
View File
@@ -0,0 +1,18 @@
Spain, 2019-01-07
Penedestic Solucions, SLP agrees to the terms of the Odoo Corporate Contributor License
Agreement v1.0.
I declare that I am authorized and able to make this agreement and sign this
declaration.
Signed,
Francisco Fernández ffernandez@planetatic.com https://github.com/FFernandez-PlanetaTIC
List of contributors:
Àngel Manonelles amanonelles@planetatic.com https://github.com/AManonelles-PlanetaTIC
Francisco Fernández ffernandez@planetatic.com https://github.com/FFernandez-PlanetaTIC
Lluís Rovira Olivé lrovira@planetatic.com https://github.com/LRovira-PlanetaTIC
Marc Poch mpoch@planetatic.com https://github.com/MPoch-PlanetaTIC
+1 -1
View File
@@ -558,7 +558,7 @@ state_ar_h,ar,"Chaco","H"
state_ar_u,ar,"Chobut","U"
state_ar_x,ar,"Córdoba","X"
state_ar_w,ar,"Corrientes","W"
state_ar_e,ar,"Ente Ríos","E"
state_ar_e,ar,"Entre Ríos","E"
state_ar_p,ar,"Formosa","P"
state_ar_y,ar,"Jujuy","Y"
state_ar_l,ar,"La Pampa","L"
1 id country_id:id name code
558 state_ar_u ar Chobut U
559 state_ar_x ar Córdoba X
560 state_ar_w ar Corrientes W
561 state_ar_e ar Ente Ríos Entre Ríos E
562 state_ar_p ar Formosa P
563 state_ar_y ar Jujuy Y
564 state_ar_l ar La Pampa L
+25
View File
@@ -367,6 +367,31 @@ class TestAPI(common.TransactionCase):
same_prefetch(empty, empty.bank_ids)
same_prefetch(empty, empty.category_id)
@mute_logger('odoo.models')
def test_60_prefetch_read(self):
""" Check that reading a field computes it on self only. """
Partner = self.env['res.partner']
field = type(Partner).company_type
self.assertTrue(field.compute and not field.store)
partner1 = Partner.create({'name': 'Foo'})
partner2 = Partner.create({'name': 'Bar', 'parent_id': partner1.id})
self.assertEqual(partner1.child_ids, partner2)
# reading partner1 should not prefetch 'company_type' on partner2
self.env.clear()
partner1 = partner1.with_prefetch()
partner1.read(['company_type'])
self.assertIn('company_type', partner1._cache)
self.assertNotIn('company_type', partner2._cache)
# reading partner1 should not prefetch 'company_type' on partner2
self.env.clear()
partner1 = partner1.with_prefetch()
partner1.read(['child_ids', 'company_type'])
self.assertIn('company_type', partner1._cache)
self.assertNotIn('company_type', partner2._cache)
@mute_logger('odoo.models')
def test_70_one(self):
""" Check method one(). """
+14
View File
@@ -117,6 +117,20 @@ class TranslationToolsTestCase(unittest.TestCase):
self.assertItemsEqual(terms,
['Form stuff', 'Blah blah blah'])
def test_translate_xml_inline4(self):
""" Test xml_translate() with inline elements with translated attrs only. """
terms = []
source = """<form string="Form stuff">
<div>
<label for="stuff"/>
<span class="fa fa-globe" title="Title stuff"/>
</div>
</form>"""
result = xml_translate(terms.append, source)
self.assertEquals(result, source)
self.assertItemsEqual(terms,
['Form stuff', '<span class="fa fa-globe" title="Title stuff"/>'])
def test_translate_xml_t(self):
""" Test xml_translate() with t-* attributes. """
terms = []
+12 -10
View File
@@ -2766,17 +2766,19 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
# retrieve results from records; this takes values from the cache and
# computes remaining fields
result = []
name_fields = [(name, self._fields[name]) for name in (stored + inherited + computed)]
data = {record: {'id': record.id} for record in self}
missing = set()
use_name_get = (load == '_classic_read')
for record in self:
try:
values = {'id': record.id}
for name, field in name_fields:
values[name] = field.convert_to_read(record[name], record, use_name_get)
result.append(values)
except MissingError:
pass
for name in (stored + inherited + computed):
convert = self._fields[name].convert_to_read
# read every field with prefetching limited to self; this avoids
# computing fields on a larger recordset than self
for record in self.with_prefetch():
try:
data[record][name] = convert(record[name], record, use_name_get)
except MissingError:
missing.add(record)
result = [data[record] for record in self if record not in missing]
return result
+5 -10
View File
@@ -163,7 +163,7 @@ def translate_xml_node(node, callback, parse, serialize):
"""
def nonspace(text):
return bool(text) and not text.isspace()
return bool(text) and len(re.sub(r'\W+', '', text)) > 1
def concat(text1, text2):
return text2 if text1 is None else text1 + (text2 or "")
@@ -255,7 +255,10 @@ def translate_xml_node(node, callback, parse, serialize):
# complete result and return it
append_content(result, todo)
result.tail = node.tail
has_text = todo_has_text or nonspace(result.text) or nonspace(result.tail)
has_text = (
todo_has_text or nonspace(result.text) or nonspace(result.tail)
or any(name in TRANSLATED_ATTRS for name in result.attrib)
)
return (has_text, result)
# translate the content of todo and append it to result
@@ -815,14 +818,6 @@ def trans_generate(lang, modules, cr):
# empty and one-letter terms are ignored, they probably are not meant to be
# translated, and would be very hard to translate anyway.
sanitized_term = (source or '').strip()
try:
# verify the minimal size without eventual xml tags
# wrap to make sure html content like '<a>b</a><c>d</c>' is accepted by lxml
wrapped = u"<div>%s</div>" % sanitized_term
node = etree.fromstring(wrapped)
sanitized_term = etree.tostring(node, encoding='unicode', method='text')
except etree.ParseError:
pass
# remove non-alphanumeric chars
sanitized_term = re.sub(r'\W+', '', sanitized_term)
if not sanitized_term or len(sanitized_term) <= 1: