Skip to content

Commit

Permalink
update _do_validate_invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 committed Dec 25, 2023
1 parent 97a7de7 commit c9a5d63
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions connector_ebisumart/models/automatic_workflow_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ def _do_validate_picking(self, picking):

def _do_validate_invoice(self, invoice):
super()._do_validate_invoice(invoice)
sale_order = invoice.mapped('invoice_line_ids.sale_line_ids.order_id')
if sale_order.cancel_in_ebisumart:
self.create_credit_note(sale_order, invoice_type="out_invoice")
purchase_order = self.env['purchase.order'].search([('origin', '=', sale_order.name)])
if not purchase_order:
return
self.create_credit_note(purchase_order, invoice_type="in_invoice")
sale_orders = invoice.mapped('invoice_line_ids.sale_line_ids.order_id')
for sale_order in sale_orders:
if sale_order.cancel_in_ebisumart:
self.create_credit_note(sale_order, invoice_type="out_invoice")
purchase_order = self.env['purchase.order'].search(
[('origin', '=', sale_order.name)],
limit="1", order="id desc"
)
if not purchase_order:
continue
self.create_credit_note(purchase_order, invoice_type="in_invoice")

def create_return_picking(self, order):
for picking in order.picking_ids.filtered(lambda r: r.state == 'done'):
Expand Down

0 comments on commit c9a5d63

Please sign in to comment.