This commit fixes all issues detected by the new pylint
gettext-variable test.
It converts some calls to the new syntax
_("Foo %s", bar)
to progressively migrate the code to the new syntax.
A few calls were not technically incorrect but still detected by the
linter.
_("Foo" +
"Bar")
has been converted to
_("Foo"
"Bar")
as it has the same effect and make sure the argument is of type
asteroid.Const instead of BinOp).
closes odoo/odoo#53683
Related: odoo/enterprise#11467
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
46 lines
2.0 KiB
Python
46 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models, _
|
|
|
|
|
|
class MrpProduction(models.Model):
|
|
_inherit = 'mrp.production'
|
|
|
|
purchase_order_count = fields.Integer(
|
|
"Count of generated PO",
|
|
compute='_compute_purchase_order_count',
|
|
groups='purchase.group_purchase_user')
|
|
|
|
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', 'procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id')
|
|
def _compute_purchase_order_count(self):
|
|
for production in self:
|
|
production.purchase_order_count = len(production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
|
production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
|
|
|
def action_view_purchase_orders(self):
|
|
self.ensure_one()
|
|
purchase_order_ids = (self.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id | self.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id).ids
|
|
action = {
|
|
'res_model': 'purchase.order',
|
|
'type': 'ir.actions.act_window',
|
|
}
|
|
if len(purchase_order_ids) == 1:
|
|
action.update({
|
|
'view_mode': 'form',
|
|
'res_id': purchase_order_ids[0],
|
|
})
|
|
else:
|
|
action.update({
|
|
'name': _("Purchase Order generated from %s", self.name),
|
|
'domain': [('id', 'in', purchase_order_ids)],
|
|
'view_mode': 'tree,form',
|
|
})
|
|
return action
|
|
|
|
def _get_document_iterate_key(self, move_raw_id):
|
|
iterate_key = super(MrpProduction, self)._get_document_iterate_key(move_raw_id)
|
|
if not iterate_key and move_raw_id.created_purchase_line_id:
|
|
iterate_key = 'created_purchase_line_id'
|
|
return iterate_key
|