porting account_invoice features in progress
This commit is contained in:
parent
04dedf864d
commit
755b34d780
@ -4,16 +4,26 @@ from ..utils import MODULE_NAME
|
|||||||
|
|
||||||
|
|
||||||
class AccountInvoice(models.Model):
|
class AccountInvoice(models.Model):
|
||||||
_inherit = "account.invoice"
|
_inherit = "account.move"
|
||||||
|
|
||||||
def invoice_print(self):
|
@staticmethod
|
||||||
self.ensure_one()
|
def check_contract_presence(sale_order_ids):
|
||||||
|
error_message = ""
|
||||||
|
if any(not so.contract_annex_id.contract_id for so in sale_order_ids):
|
||||||
|
error_message = _("There is a Sale order without binding contract.")
|
||||||
|
if any(not so.contract_annex_id for so in sale_order_ids):
|
||||||
|
error_message = _("There is a Sale order without annex.")
|
||||||
|
if error_message:
|
||||||
|
raise UserError(error_message)
|
||||||
|
|
||||||
|
def action_invoice_print(self):
|
||||||
|
'''
|
||||||
for so in self.env["sale.order"].search([]):
|
for so in self.env["sale.order"].search([]):
|
||||||
if self.id in so.invoice_ids.ids:
|
if self.id in so.invoice_ids.ids:
|
||||||
order = so
|
order = so
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
return super().invoice_print()
|
return super().action_invoice_print()
|
||||||
|
|
||||||
if not order.contract_annex_id or not order.contract_annex_id.contract_id:
|
if not order.contract_annex_id or not order.contract_annex_id.contract_id:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
@ -21,8 +31,20 @@ class AccountInvoice(models.Model):
|
|||||||
"There is no binding contract. It is necessary to link the order with the annex to the contract."
|
"There is no binding contract. It is necessary to link the order with the annex to the contract."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.sent = True
|
self.sent = True
|
||||||
|
'''
|
||||||
|
|
||||||
|
sale_orders_ids = self.env["sale.order"].search([
|
||||||
|
("invoice_ids", "in", self.ids)
|
||||||
|
])
|
||||||
|
if not sale_orders_ids:
|
||||||
|
return super().action_invoice_print()
|
||||||
|
|
||||||
|
self.check_contract_presence(sale_orders_ids)
|
||||||
|
self.filtered(lambda inv: not inv.is_move_sent).write({'is_move_sent': True})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
view = self.env.ref(
|
view = self.env.ref(
|
||||||
"{}.res_partner_wizard_print_document_view".format(MODULE_NAME)
|
"{}.res_partner_wizard_print_document_view".format(MODULE_NAME)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user