From 4537e1813a7b3a5a4f6355ae6bc6394407a60e9b Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 27 Nov 2019 19:09:33 +0100 Subject: [PATCH] [FIX] Alignments --- .../models/account_invoice.py | 16 ++++++++-------- .../models/account_journal.py | 12 ++++++------ account_operating_unit/models/account_move.py | 17 ++++++++++------- .../models/account_payment.py | 2 +- stock_operating_unit/model/stock_warehouse.py | 8 ++++---- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/account_operating_unit/models/account_invoice.py b/account_operating_unit/models/account_invoice.py index 399b594ec9..7b5bcde49b 100644 --- a/account_operating_unit/models/account_invoice.py +++ b/account_operating_unit/models/account_invoice.py @@ -10,14 +10,14 @@ class AccountInvoice(models.Model): _inherit = "account.invoice" - operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit', - default=lambda self: - self.env['res.users']. - operating_unit_default_get(self._uid), - domain="[('user_ids', '=', uid)]", - readonly=True, - states={'draft': [('readonly', - False)]}) + operating_unit_id = fields.Many2one( + comodel_name='operating.unit', + string='Operating Unit', + default=lambda self: self.env['res.users'].operating_unit_default_get( + self._uid), + domain="[('user_ids', '=', uid)]", + readonly=True, + states={'draft': [('readonly', False)]}) @api.onchange('operating_unit_id') def _onchange_operating_unit(self): diff --git a/account_operating_unit/models/account_journal.py b/account_operating_unit/models/account_journal.py index f8bad2f4bf..cb7fdf738a 100644 --- a/account_operating_unit/models/account_journal.py +++ b/account_operating_unit/models/account_journal.py @@ -9,12 +9,12 @@ class AccountJournal(models.Model): _inherit = "account.journal" - operating_unit_id = fields.Many2one(comodel_name='operating.unit', - string='Operating Unit', - domain="[('user_ids', '=', uid)]", - help="Operating Unit that will be " - "used in payments, when this " - "journal is used.") + operating_unit_id = fields.Many2one( + comodel_name='operating.unit', + string='Operating Unit', + domain="[('user_ids', '=', uid)]", + help="Operating Unit that will be used in payments, " + "when this journal is used.") @api.multi @api.constrains('type') diff --git a/account_operating_unit/models/account_move.py b/account_operating_unit/models/account_move.py index dbe701aa56..d68eab0c7a 100644 --- a/account_operating_unit/models/account_move.py +++ b/account_operating_unit/models/account_move.py @@ -9,8 +9,10 @@ class AccountMoveLine(models.Model): _inherit = "account.move.line" - operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit', - domain="[('user_ids', '=', uid)]",) + operating_unit_id = fields.Many2one( + comodel_name='operating.unit', + string='Operating Unit', + domain="[('user_ids', '=', uid)]",) @api.model def create(self, vals): @@ -54,11 +56,12 @@ def _check_move_operating_unit(self): class AccountMove(models.Model): _inherit = "account.move" - operating_unit_id = fields.Many2one('operating.unit', - 'Default operating unit', - domain="[('user_ids', '=', uid)]", - help="This operating unit will " - "be defaulted in the move lines.") + operating_unit_id = fields.Many2one( + comodel_name='operating.unit', + string='Default operating unit', + domain="[('user_ids', '=', uid)]", + help="This operating unit will be " + "defaulted in the move lines.") @api.multi def _prepare_inter_ou_balancing_move_line(self, move, ou_id, diff --git a/account_operating_unit/models/account_payment.py b/account_operating_unit/models/account_payment.py index b17e9ba693..d19bb7167b 100644 --- a/account_operating_unit/models/account_payment.py +++ b/account_operating_unit/models/account_payment.py @@ -23,7 +23,7 @@ def _compute_operating_unit_id(self): def _get_counterpart_move_line_vals(self, invoice=False): res = super(AccountPayment, self)._get_counterpart_move_line_vals(invoice=invoice) - if len(invoice) == 1: + if invoice and len(invoice) == 1: res['operating_unit_id'] = invoice.operating_unit_id.id or False else: res['operating_unit_id'] = self.operating_unit_id.id or False diff --git a/stock_operating_unit/model/stock_warehouse.py b/stock_operating_unit/model/stock_warehouse.py index f1832f739f..d3daa77f3a 100644 --- a/stock_operating_unit/model/stock_warehouse.py +++ b/stock_operating_unit/model/stock_warehouse.py @@ -46,7 +46,7 @@ def _check_location(self): if (rec.warehouse_id and rec.location_id and rec.warehouse_id.operating_unit_id != rec.location_id.operating_unit_id): - raise UserError( - _('Configuration Error. The Operating Unit of the ' - 'Warehouse and the Location must be the same. ') - ) + raise UserError( + _('Configuration Error. The Operating Unit of the ' + 'Warehouse and the Location must be the same. ') + )