Skip to content

Commit

Permalink
Merge pull request #706 from kmee/14.0_extract_l10n_br_pos_remove_att…
Browse files Browse the repository at this point in the history
…achment

[REM] Non necessary code
  • Loading branch information
lfdivino committed Jan 18, 2023
2 parents 6a90a3f + b9a751f commit ceb15e4
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions l10n_br_pos/models/pos_order.py
Expand Up @@ -263,28 +263,6 @@ def _amount_all(self):
for order in self:
order._compute_amount()

def _save_attachment(
self, file_name="", file_content="", file_type="application/xml"
):
self.ensure_one()
attachment = self.env["ir.attachment"]
domain = [
("res_model", "=", self._name),
("res_id", "=", self.id),
("name", "=", file_name),
]
attachment_ids = attachment.search(domain)
attachment_ids.unlink()
vals = {
"name": file_name,
"store_fname": file_name,
"res_model": self._name,
"res_id": self.id,
"datas": file_content.encode("utf-8"),
"mimetype": file_type,
}
return attachment.create(vals)

@api.model
def _process_order(self, order, draft, existing_order):

Expand All @@ -298,18 +276,6 @@ def _process_order(self, order, draft, existing_order):
),
)._process_order(order, draft, existing_order)

if order.get("authorization_file"):
order.document_file_id = order._save_attachment(
file_name=order.document_key + ".xml",
file_content=order.pop("authorization_file"),
).id

if order.get("cancel_file"):
order.cancel_document_file_id = order._save_attachment(
file_name=order.document_key + ".xml",
file_content=order.pop("cancel_file"),
).id

return order_id

@api.model
Expand Down Expand Up @@ -449,9 +415,6 @@ def cancelar_order(self, result):
order.write({"state": "cancel"})

order._populate_cancel_order_fields(result)
order.cancel_document_file_id = order._save_attachment(
file_name=result["chave_cfe"] + ".xml", file_content=result["xml"]
).id

order.with_context(
mail_create_nolog=True,
Expand Down

0 comments on commit ceb15e4

Please sign in to comment.