Skip to content

Commit

Permalink
Merge PR OCA#2751 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by rvalyi
  • Loading branch information
OCA-git-bot committed Oct 27, 2023
2 parents 11d667f + 9057f09 commit 783aa13
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 25 deletions.
9 changes: 5 additions & 4 deletions l10n_br_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def _compute_amount(self):
else:
sign = 1
inv_line_ids = move.line_ids.filtered(
lambda l: not l.exclude_from_invoice_tab
lambda line: not line.exclude_from_invoice_tab
)
move.amount_untaxed = sum(inv_line_ids.mapped("amount_untaxed"))
move.amount_tax = sum(inv_line_ids.mapped("amount_tax"))
Expand Down Expand Up @@ -431,8 +431,9 @@ def _recompute_payment_terms_lines(self):
result = super()._recompute_payment_terms_lines()
if self.document_number:
terms_lines = self.line_ids.filtered(
lambda l: l.account_id.user_type_id.type in ("receivable", "payable")
and l.move_id.document_type_id
lambda line: line.account_id.user_type_id.type
in ("receivable", "payable")
and line.move_id.document_type_id
)
terms_lines.sorted(lambda line: line.date_maturity)
for idx, terms_line in enumerate(terms_lines):
Expand Down Expand Up @@ -656,7 +657,7 @@ def _finalize_invoices(self, invoices):

def create_wh_invoices(self):
for move in self:
for line in move.line_ids.filtered(lambda l: l.tax_line_id):
for line in move.line_ids.filtered(lambda line: line.tax_line_id):
# Create Wh Invoice only for supplier invoice
if line.move_id and line.move_id.type != "in_invoice":
continue
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_account/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def create(self, vals_list):
return results

def write(self, values):
non_dummy = self.filtered(lambda l: l.fiscal_document_line_id)
non_dummy = self.filtered(lambda line: line.fiscal_document_line_id)
self._inject_shadowed_fields([values])
if values.get("move_id") and len(non_dummy) == len(self):
# we can write the document_id in all lines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_create_payment_order(self):
self.invoice_cef.action_post()

# Verificar os campos CNAB na account.move.line
for line in self.invoice_cef.line_ids.filtered(lambda l: l.own_number):
for line in self.invoice_cef.line_ids.filtered(lambda line: line.own_number):
assert (
line.own_number
), "own_number field is not filled in created Move Line."
Expand Down
8 changes: 4 additions & 4 deletions l10n_br_cnab_structure/models/cnab_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ class CNABBatch(models.Model):

def get_header(self):
"Returns the batch header record"
return self.line_ids.filtered(lambda l: l.type == "header")
return self.line_ids.filtered(lambda line: line.type == "header")

def get_trailer(self):
"Returns the batch trailer record"
return self.line_ids.filtered(lambda l: l.type == "trailer")
return self.line_ids.filtered(lambda line: line.type == "trailer")

def get_segments(self):
"Returns the batch segments records"
return self.line_ids.filtered(lambda l: l.type == "segment")
return self.line_ids.filtered(lambda line: line.type == "segment")

def output(self, bank_lines, seq_batch):
"""
Expand Down Expand Up @@ -103,7 +103,7 @@ def output(self, bank_lines, seq_batch):
return batch

def unlink(self):
lines = self.filtered(lambda l: l.state != "draft")
lines = self.filtered(lambda line: line.state != "draft")
if lines:
raise UserError(_("You cannot delete an CNAB Batch which is not draft !"))
return super().unlink()
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_cnab_structure/models/cnab_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _compute_name(self):
line.name = f"{line.cnab_structure_id.name} -> {name}"

def unlink(self):
lines = self.filtered(lambda l: l.state != "draft")
lines = self.filtered(lambda line: line.state != "draft")
if lines:
raise UserError(_("You cannot delete an CNAB Line which is not draft !"))
return super().unlink()
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_cnab_structure/models/cnab_line_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _compute_size(self):
f.size = f.end_pos - f.start_pos + 1

def unlink(self):
lines = self.filtered(lambda l: l.state != "draft")
lines = self.filtered(lambda line: line.state != "draft")
if lines:
raise UserError(_("You cannot delete an CNAB Field which is not draft !"))
return super().unlink()
Expand Down
16 changes: 10 additions & 6 deletions l10n_br_cnab_structure/models/cnab_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,15 @@ def _onchange_cnab_format(self):

def get_header(self):
"Returns the file header record"
return self.line_ids.filtered(lambda l: l.type == "header" and not l.batch_id)
return self.line_ids.filtered(
lambda line: line.type == "header" and not line.batch_id
)

def get_trailer(self):
"Returns the file trailer record"
return self.line_ids.filtered(lambda l: l.type == "trailer" and not l.batch_id)
return self.line_ids.filtered(
lambda line: line.type == "trailer" and not line.batch_id
)

def output_dicts(self, pay_order):
"""
Expand Down Expand Up @@ -335,7 +339,7 @@ def _compute_content_source_model_id(self):
)

def unlink(self):
lines = self.filtered(lambda l: l.state != "draft")
lines = self.filtered(lambda line: line.state != "draft")
if lines:
raise UserError(
_("You cannot delete an CNAB Structure which is not draft !")
Expand Down Expand Up @@ -377,13 +381,13 @@ def check_structure(self):
)

segment_lines = self.line_ids.filtered(
lambda l: l.type == "segment" and not l.batch_id
lambda line: line.type == "segment" and not line.batch_id
)
header_line = self.line_ids.filtered(
lambda l: l.type == "header" and not l.batch_id
lambda line: line.type == "header" and not line.batch_id
)
trailer_line = self.line_ids.filtered(
lambda l: l.type == "trailer" and not l.batch_id
lambda line: line.type == "trailer" and not line.batch_id
)

if segment_lines and self.cnab_format == "240":
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_cnab_structure/models/l10n_br_cnab_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def _get_reconciliation_items(self, move_id):
# If it is an outbound payment, the counterpart will be an debit.
# If inbound will be a credit
debit_or_credit = "debit" if self.move_line_ids[0].balance < 0 else "credit"
move_lines = self.move_line_ids.sorted(key=lambda l: l.date_maturity)
move_lines = self.move_line_ids.sorted(key=lambda line: line.date_maturity)
for index, move_line in enumerate(move_lines):
line_balance = abs(move_line.balance)
# the total value of counterpart move lines must be equal to balance in return event
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_fiscal/models/document_fiscal_mixin_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _get_amount_lines(self):
def _get_product_amount_lines(self):
"""Get object lines instaces used to compute fields"""
fiscal_line_ids = self._get_amount_lines()
return fiscal_line_ids.filtered(lambda l: l.product_id.type != "service")
return fiscal_line_ids.filtered(lambda line: line.product_id.type != "service")

@api.model
def _get_amount_fields(self):
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_fiscal/models/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def action_draft(self):
self.line_ids.write({"state": "draft"})

def unlink(self):
operations = self.filtered(lambda l: l.state == "approved")
operations = self.filtered(lambda line: line.state == "approved")
if operations:
raise UserError(_("You cannot delete an Operation which is not draft !"))
return super().unlink()
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_fiscal/models/operation_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def action_review(self):
self.write({"state": "review"})

def unlink(self):
lines = self.filtered(lambda l: l.state == "approved")
lines = self.filtered(lambda line: line.state == "approved")
if lines:
raise UserError(
_("You cannot delete an Operation Line which is not draft !")
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_fiscal/models/tax_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def action_draft(self):
self.write({"state": "draft"})

def unlink(self):
operations = self.filtered(lambda l: l.state == "approved")
operations = self.filtered(lambda line: line.state == "approved")
if operations:
raise UserError(
_("You cannot delete an Tax Definition which is not draft !")
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _amount_by_group(self):
res.setdefault(group, {"amount": 0.0, "base": 0.0})
res[group]["amount"] += computed_tax.get("tax_value", 0.0)
res[group]["base"] += computed_tax.get("base", 0.0)
res = sorted(res.items(), key=lambda l: l[0].sequence)
res = sorted(res.items(), key=lambda line: line[0].sequence)
order.amount_by_group = [
(
line[0].name,
Expand Down
4 changes: 3 additions & 1 deletion l10n_br_sale_stock/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class SaleOrder(models.Model):
def _compute_get_button_create_invoice_invisible(self):
button_create_invoice_invisible = False

lines = self.order_line.filtered(lambda l: l.invoice_status == "to invoice")
lines = self.order_line.filtered(
lambda line: line.invoice_status == "to invoice"
)

# Somente depois do Pedido confirmado o botão pode aparecer
if self.state != "sale":
Expand Down

0 comments on commit 783aa13

Please sign in to comment.