Skip to content

Commit

Permalink
[FIX] l10n_it_delivery_note: remove delivery note count from SO
Browse files Browse the repository at this point in the history
Since it's a not used anywhere, and it's a duplicate from l10n_it_delivery_note_order_link
  • Loading branch information
renda-dev committed Jul 18, 2024
1 parent 06235d7 commit 39991cb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 41 deletions.
40 changes: 0 additions & 40 deletions l10n_it_delivery_note/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
class SaleOrder(models.Model):
_inherit = "sale.order"

delivery_note_ids = fields.Many2many(
"stock.delivery.note", compute="_compute_delivery_notes"
)
delivery_note_count = fields.Integer(compute="_compute_delivery_notes")

default_transport_condition_id = fields.Many2one(
"stock.picking.transport.condition",
string="Condition of transport",
Expand Down Expand Up @@ -57,15 +52,6 @@ def onchange_partner_id_shipping_info(self):

self.update(values)

def _compute_delivery_notes(self):
for order in self:
delivery_notes = order.order_line.mapped(
"delivery_note_line_ids.delivery_note_id"
)

order.delivery_note_ids = delivery_notes
order.delivery_note_count = len(delivery_notes)

def _assign_delivery_notes_invoices(self, invoice_ids):
order_lines = self.mapped("order_line").filtered(
lambda l: l.is_invoiced and l.delivery_note_line_ids
Expand Down Expand Up @@ -126,32 +112,6 @@ def _create_invoices(self, grouped=False, final=False, date=None):

return invoice_ids

def goto_delivery_notes(self, **kwargs):
delivery_notes = self.mapped("delivery_note_ids")
action = self.env["ir.actions.act_window"]._for_xml_id(
"l10n_it_delivery_note.stock_delivery_note_action"
)
action.update(kwargs)

if len(delivery_notes) > 1:
action["domain"] = [("id", "in", delivery_notes.ids)]

elif len(delivery_notes) == 1:
action["views"] = [
(
self.env.ref(
"l10n_it_delivery_note.stock_delivery_note_form_view"
).id,
"form",
)
]
action["res_id"] = delivery_notes.id

else:
action = {"type": "ir.actions.act_window_close"}

return action


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_delivery_note/wizard/sale_advance_payment_inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SaleAdvancePaymentInv(models.TransientModel):
_inherit = "sale.advance.payment.inv"

def _default_step(self):
states = self.sale_order_ids.mapped("delivery_note_ids.state")
states = self.sale_order_ids.mapped("picking_ids.delivery_note_id.state")

if any(s == "draft" for s in states):
return DOMAIN_WIZARD_STEPS[1]
Expand Down
20 changes: 20 additions & 0 deletions l10n_it_delivery_note_order_link/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,23 @@ def _compute_delivery_notes(self):

order.delivery_note_ids = delivery_notes
order.delivery_note_count = len(delivery_notes)

def goto_delivery_notes(self, **kwargs):
delivery_notes = self.mapped("delivery_note_ids")

action = self.env["ir.actions.act_window"]._for_xml_id(
"l10n_it_delivery_note.stock_delivery_note_action"
)
action.update(kwargs)
if len(delivery_notes) > 1:
action["domain"] = [("id", "in", delivery_notes.ids)]
elif len(delivery_notes) == 1:
action["views"] = [
(
self.env.ref(
"l10n_it_delivery_note.stock_delivery_note_form_view"
).id,
"form",
)
]
action["res_id"] = delivery_notes.id

0 comments on commit 39991cb

Please sign in to comment.