Skip to content

Commit

Permalink
[MIG] l10n_it_delivery_note: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Sep 13, 2024
1 parent 4d99100 commit aaba6b1
Show file tree
Hide file tree
Showing 48 changed files with 1,600 additions and 1,154 deletions.
11 changes: 11 additions & 0 deletions l10n_it_delivery_note/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Copyright 2023 Nextev Srl

def post_init_hook(env):
"""
Create DN types and their sequences after installing the module
if they're not already exist
"""
companies = env["res.company"].search([])
for company in companies:
env["stock.delivery.note.type"].create_dn_types(company)

from . import controllers
from . import mixins
from . import models
Expand Down
13 changes: 11 additions & 2 deletions l10n_it_delivery_note/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,37 @@
"author": "Marco Calcagni, Gianmarco Conte, Link IT Europe Srl, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-italy",
"version": "16.0.1.4.5",
"version": "17.5.1.0.0",
"category": "Localization/Italy",
"license": "AGPL-3",
"maintainers": ["MarcoCalcagni", "aleuffre", "renda-dev"],
"depends": [
"delivery_carrier_partner",
"l10n_it_delivery_note_base",
"mail",
"sale",
"sale_stock",
"stock_account",
"stock_delivery",
"portal",
"product",
],
"data": [
"security/ir.model.access.csv",
"security/ir_module_category.xml",
"security/ir_rule.xml",
"security/res_groups.xml",
"security/res_users.xml",
"data/delivery_note_data.xml",
"report/report_delivery_note.xml",
"views/account_move.xml",
"views/res_config_settings.xml",
"views/res_partner.xml",
"views/sale_order.xml",
"views/stock_delivery_note_type.xml",
"views/stock_picking_goods_appearance.xml",
"views/stock_picking_transport_condition.xml",
"views/stock_picking_transport_method.xml",
"views/stock_picking_transport_reason.xml",
"views/stock_delivery_note.xml",
"views/stock_picking.xml",
"views/portal_templates.xml",
Expand All @@ -56,4 +64,5 @@
"l10n_it_delivery_note/static/src/scss/stock_delivery_note.scss",
],
},
"post_init_hook": "post_init_hook",
}
109 changes: 63 additions & 46 deletions l10n_it_delivery_note/controllers/portal.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from odoo import _
from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager
from odoo.exceptions import AccessError, MissingError
from odoo.osv.expression import OR
from odoo.http import request, route

from odoo.addons.portal.controllers.portal import CustomerPortal
from odoo.addons.portal.controllers.portal import pager as portal_pager


class DNCustomerPortal(CustomerPortal):
def _get_delivery_note_domain(self, search_in=False):
def _get_delivery_note_domain(self):
domain = [("state", "in", ["confirm", "invoiced", "done"])]
if search_in:
domain += search_in
return domain

def _prepare_home_portal_values(self, counters):
Expand All @@ -27,77 +24,95 @@ def _prepare_home_portal_values(self, counters):
values["dn_count"] = dn_count
return values

@route(
["/my/delivery-notes", "/my/delivery-notes/page/<int:page>"],
type="http",
auth="user",
website=True,
)
def portal_my_delivery_notes(
def _get_delivery_notes_searchbar_sortings(self):
return {
"date": {"label": _("Delivery Note Date"), "order": "date desc"},
"name": {"label": _("Delivery Note #"), "order": "name"},
}

def _get_delivery_notes_searchbar_inputs(self):
return {
"name": {"input": "name", "label": _("Search in Description")},
}

def _prepare_my_delivery_notes_values(
self,
page=1,
date_begin=None,
date_end=None,
sortby=None,
search="",
search_in="name",
**kw,
**kwargs,
):
values = self._prepare_portal_layout_values()
DeliveryNote = request.env["stock.delivery.note"]

searchbar_sortings = {
"date": {"label": _("Delivery Note Date"), "order": "date desc"},
"name": {"label": _("Delivery Note #"), "order": "name"},
}
searchbar_inputs = {
"name": {
"input": "name",
"label": _('Search <span class="nolabel"> Name</span>'),
"domain": [("name", "ilike", search)],
},
}
url = "/my/delivery-notes"
_items_per_page = 100

search_domain = searchbar_inputs[search_in]["domain"] if search_in else []
# default sortby order
if not sortby:
sortby = "date"

searchbar_sortings = self._get_delivery_notes_searchbar_sortings()
searchbar_inputs = self._get_delivery_notes_searchbar_inputs()

sort_order = searchbar_sortings[sortby]["order"]
domain = self._get_delivery_note_domain()

# count for pager
dn_count = DeliveryNote.search_count(
self._get_delivery_note_domain(search_domain)
)
# make pager
pager = portal_pager(
url="/my/delivery-notes",
url_args={"sortby": sortby, "search_in": search_in, "search": "search"},
total=dn_count,
if date_begin and date_end:
domain += [("date", ">", date_begin), ("date", "<=", date_end)]

if search and search_in:
search_domain = []
if search_in == "name":
search_domain = OR([search_domain, [("name", "ilike", search)]])
domain += search_domain

pager_values = portal_pager(
url=url,
total=DeliveryNote.search_count(domain),
page=page,
step=self._items_per_page,
step=_items_per_page,
url_args={
"date_begin": date_begin,
"date_end": date_end,
"sortby": sortby,
"search_in": search_in,
"search": search,
},
)
# search the count to display, according to the pager data

delivery_note = DeliveryNote.search(
self._get_delivery_note_domain(search_domain),
order=sort_order,
limit=self._items_per_page,
offset=pager["offset"],
domain, order=sort_order, limit=_items_per_page, offset=pager_values["offset"]
)

values.update(
{
"date": date_begin,
"delivery_notes": delivery_note,
"page_name": "delivery_notes",
"pager": pager,
"default_url": "/my/delivery-notes",
"default_url": url,
"pager": pager_values,
"searchbar_sortings": searchbar_sortings,
"searchbar_inputs": searchbar_inputs,
"search_in": search_in,
"search": search,
"sortby": sortby,
}
)
return values

@route(
["/my/delivery-notes", "/my/delivery-notes/page/<int:page>"],
type="http",
auth="user",
website=True,
)
def portal_my_delivery_notes(self, **kwargs):
values = self._prepare_my_delivery_notes_values(**kwargs)
request.session["my_delivery_notes_history"] = values["delivery_notes"].ids[:100]
return request.render("l10n_it_delivery_note.portal_my_delivery_notes", values)

def _dn_get_page_view_values(self, dn, access_token, **kwargs):
Expand All @@ -111,11 +126,11 @@ def _dn_get_page_view_values(self, dn, access_token, **kwargs):

@route(["/my/delivery-notes/<int:dn_id>"], type="http", auth="user", website=True)
def portal_my_delivery_note_detail(
self, dn_id, access_token=None, report_type=None, download=False, **kw
self, dn_id, access_token=None, report_type=None, download=False, **kwargs
):
try:
delivery_note_sudo = self._document_check_access(
"stock.delivery.note", dn_id, access_token
"stock.delivery.note", dn_id, access_token=access_token
)
except (AccessError, MissingError):
return request.redirect("/my")
Expand All @@ -128,6 +143,8 @@ def portal_my_delivery_note_detail(
download=download,
)

values = self._dn_get_page_view_values(delivery_note_sudo, access_token, **kw)
values = self._dn_get_page_view_values(
delivery_note_sudo, access_token, **kwargs
)

return request.render("l10n_it_delivery_note.portal_delivery_note_page", values)
55 changes: 55 additions & 0 deletions l10n_it_delivery_note/data/delivery_note_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (c) 2019, Link IT Europe Srl
@author: Matteo Bilotta <[email protected]>
-->
<odoo noupdate="1">

<!-- Conditions of transport -->
<record id="transport_condition_PF" model="stock.picking.transport.condition">
<field name="name">Carriage paid</field>
</record>
<record id="transport_condition_PA" model="stock.picking.transport.condition">
<field name="name">Carriage forward</field>
</record>
<record id="transport_condition_PAF" model="stock.picking.transport.condition">
<field name="name">Charged in invoice</field>
</record>

<!-- Goods appearance -->
<record id="goods_appearance_CAR" model="stock.picking.goods.appearance">
<field name="name">Box</field>
</record>
<record id="goods_appearance_BAN" model="stock.picking.goods.appearance">
<field name="name">Pallet</field>
</record>
<record id="goods_appearance_SFU" model="stock.picking.goods.appearance">
<field name="name">Bulk</field>
</record>
<record id="goods_appearance_CBA" model="stock.picking.goods.appearance">
<field name="name">Box / Pallet</field>
</record>

<!-- Reasons of transport -->
<record id="transport_reason_VEN" model="stock.picking.transport.reason">
<field name="name">Sale</field>
</record>
<record id="transport_reason_VIS" model="stock.picking.transport.reason">
<field name="name">Goods on approval</field>
</record>
<record id="transport_reason_RES" model="stock.picking.transport.reason">
<field name="name">Returned</field>
</record>

<!-- Methods of transport -->
<record id="transport_method_MIT" model="stock.picking.transport.method">
<field name="name">Sender</field>
</record>
<record id="transport_method_DES" model="stock.picking.transport.method">
<field name="name">Recipient</field>
</record>
<record id="transport_method_COR" model="stock.picking.transport.method">
<field name="name">Carrier</field>
</record>

</odoo>
16 changes: 0 additions & 16 deletions l10n_it_delivery_note/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,6 @@ msgstr "Selettore DdT"
msgid "Delivery Note Types"
msgstr "Tipi DdT"

#. module: l10n_it_delivery_note
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_stock_picking__delivery_note_visible
msgid "Delivery Note Visible"
msgstr "DdT visibile"

#. module: l10n_it_delivery_note
#: model:ir.actions.act_window,name:l10n_it_delivery_note.stock_delivery_note_action
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_account_bank_statement_line__delivery_note_ids
Expand Down Expand Up @@ -1759,17 +1754,6 @@ msgstr "UdM"
msgid "Update to now"
msgstr "Aggiorna ad adesso"

#. module: l10n_it_delivery_note
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_stock_picking__use_advanced_behaviour
msgid "Use Advanced Behaviour"
msgstr "Usa funzioni avanzate"

#. module: l10n_it_delivery_note
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_res_config_settings__group_use_advanced_delivery_notes
#: model:res.groups,name:l10n_it_delivery_note.use_advanced_delivery_notes
msgid "Use Advanced DN Features"
msgstr "Usa Funzioni Avanzate DdT"

#. module: l10n_it_delivery_note
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_stock_picking__use_delivery_note
msgid "Use Delivery Note"
Expand Down
16 changes: 0 additions & 16 deletions l10n_it_delivery_note/i18n/l10n_it_delivery_note.pot
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,6 @@ msgstr ""
msgid "Delivery Note Types"
msgstr ""

#. module: l10n_it_delivery_note
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_stock_picking__delivery_note_visible
msgid "Delivery Note Visible"
msgstr ""

#. module: l10n_it_delivery_note
#: model:ir.actions.act_window,name:l10n_it_delivery_note.stock_delivery_note_action
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_account_bank_statement_line__delivery_note_ids
Expand Down Expand Up @@ -1682,17 +1677,6 @@ msgstr ""
msgid "Update to now"
msgstr ""

#. module: l10n_it_delivery_note
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_stock_picking__use_advanced_behaviour
msgid "Use Advanced Behaviour"
msgstr ""

#. module: l10n_it_delivery_note
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_res_config_settings__group_use_advanced_delivery_notes
#: model:res.groups,name:l10n_it_delivery_note.use_advanced_delivery_notes
msgid "Use Advanced DN Features"
msgstr ""

#. module: l10n_it_delivery_note
#: model:ir.model.fields,field_description:l10n_it_delivery_note.field_stock_picking__use_delivery_note
msgid "Use Delivery Note"
Expand Down
11 changes: 0 additions & 11 deletions l10n_it_delivery_note/migrations/14.0.3.0.0/post-migrate.py

This file was deleted.

5 changes: 5 additions & 0 deletions l10n_it_delivery_note/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
from . import account_invoice_line
from . import res_company
from . import res_config_settings
from . import stock_delivery_note_type
from . import stock_picking_goods_appearance
from . import stock_picking_transport_condition
from . import stock_picking_transport_method
from . import stock_picking_transport_reason
from . import res_partner
from . import sale_order
from . import sale_order_line
Expand Down
Loading

0 comments on commit aaba6b1

Please sign in to comment.