[ADD] Print contract annex using btn 'Print Invoice' from invoice form

This commit is contained in:
Stepan Savelyev 2020-03-18 18:44:46 +05:00
parent c6adc05d44
commit 22a7f6589b
3 changed files with 61 additions and 22 deletions

View File

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0-20191106\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-05 13:43+0000\n"
"PO-Revision-Date: 2020-03-05 13:43+0000\n"
"POT-Creation-Date: 2020-03-18 13:42+0000\n"
"PO-Revision-Date: 2020-03-18 13:42+0000\n"
"Last-Translator: Stepan Savelyev\n"
"Language-Team: RYDLAB\n"
"MIME-Version: 1.0\n"
@ -577,6 +577,11 @@ msgstr "Срок монтажа изделий"
msgid "Institutional-Legal Form"
msgstr "Огранизационно-правовая форма"
#. module: client_contracts
#: model:ir.model,name:client_contracts.model_account_invoice
msgid "Invoice"
msgstr "Счёт"
#. module: client_contracts
#: model:res.partner.contract.field,name:client_contracts.contract_field_partner_kpp
#: model:res.partner.contract.field,name:client_contracts.contract_field_seller_kpp
@ -613,11 +618,6 @@ msgstr "Последний раз обновил"
msgid "Last Updated on"
msgstr "Последнее обновление"
#. module: client_contracts
#: model:ir.model,name:client_contracts.model_crm_lead
msgid "Lead/Opportunity"
msgstr "Лид / Потенциальная сделка"
#. module: client_contracts
#: model:ir.ui.view,arch_db:client_contracts.res_partner_contract_annex_view_form
msgid "Leave empty for compute"
@ -881,26 +881,12 @@ msgid "Print Form of Contract"
msgstr "Форма печати договора"
#. module: client_contracts
#: code:addons/client_contracts/models/account_invoice.py:31
#: code:addons/client_contracts/models/res_partner_contract_annex.py:110
#, python-format
msgid "Print Form of Contract Annex"
msgstr "Форма печати приложения к договору"
#. module: client_contracts
#: model:ir.model,name:client_contracts.model_res_partner_template_print
msgid "Print Template"
msgstr "Шаблон печати"
#. module: client_contracts
#: model:ir.model,name:client_contracts.model_res_partner_template_print_contract
msgid "Print Template Contract"
msgstr "Вложение-шаблон договора"
#. module: client_contracts
#: model:ir.model,name:client_contracts.model_res_partner_template_print_annex
msgid "Print Template Contract Annex"
msgstr "Вложение-шаблон приложения к договору"
#. module: client_contracts
#: selection:res.partner.document.template,company_type:0
msgid "Private Limited Company"
@ -911,6 +897,11 @@ msgstr "Общество с ограниченной ответственнос
msgid "Quotation"
msgstr "Оферта"
#. module: client_contracts
#: model:ir.model.fields,field_description:client_contracts.field_res_partner_contract_res_model
msgid "Related Document Model Name"
msgstr "Related Document Model Name"
#. module: client_contracts
#: model:ir.ui.view,arch_db:client_contracts.res_partner_contract_form
msgid "Renew"
@ -1055,6 +1046,12 @@ msgstr "Тип шаблона"
msgid "Templates"
msgstr "Шаблоны"
#. module: client_contracts
#: code:addons/client_contracts/models/account_invoice.py:20
#, python-format
msgid "There is no binding contract. It is necessary to link the order with the annex to the contract."
msgstr "Отсутствует связанный договор. Необходимо связать заказ с приложением к договору."
#. module: client_contracts
#: model:ir.model.fields,help:client_contracts.field_res_partner_name_write
#: model:ir.model.fields,help:client_contracts.field_res_users_name_write

View File

@ -1,3 +1,4 @@
from . import account_invoice
from . import res_partner
from . import res_partner_contract
from . import res_partner_contract_annex

41
models/account_invoice.py Normal file
View File

@ -0,0 +1,41 @@
from odoo import models, _
from odoo.exceptions import UserError
from ..utils import MODULE_NAME
class AccountInvoice(models.Model):
_inherit = "account.invoice"
def invoice_print(self):
self.ensure_one()
for so in self.env["sale.order"].search([]):
if self.id in so.invoice_ids.ids:
order = so
break
else:
return super().invoice_print()
if not order.contract_annex_id or not order.contract_annex_id.contract_id:
raise UserError(
_(
"There is no binding contract. It is necessary to link the order with the annex to the contract."
)
)
self.sent = True
view = self.env.ref(
"{}.res_partner_wizard_print_document_view".format(MODULE_NAME)
)
return {
"name": _("Print Form of Contract Annex"),
"type": "ir.actions.act_window",
"res_model": "res.partner.contract.wizard",
"view_mode": "form",
"view_id": view.id,
"target": "new",
"context": {
"self_id": order.contract_annex_id.id,
"active_model": "res.partner.contract.annex",
},
}