Skip to content

Commit

Permalink
[MIG] l10n_it_delivery_note: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso authored and jado95 committed Nov 11, 2022
1 parent 023b2a9 commit abd4b01
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 140 deletions.
10 changes: 5 additions & 5 deletions l10n_it_delivery_note/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ ITA - Documento di trasporto
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_delivery_note
:target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_delivery_note
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_delivery_note
:target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_delivery_note
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/122/14.0
:target: https://runbot.odoo-community.org/runbot/122/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -155,7 +155,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_delivery_note%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_delivery_note%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -203,6 +203,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-As400it|

This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_delivery_note>`_ project on GitHub.
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_delivery_note>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
8 changes: 6 additions & 2 deletions l10n_it_delivery_note/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Marco Calcagni, Gianmarco Conte, Link IT Europe Srl, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-italy",
"version": "14.0.1.0.14",
"version": "16.0.1.0.0",
"category": "Localization/Italy",
"license": "AGPL-3",
"maintainers": ["As400it"],
Expand All @@ -32,7 +32,6 @@
"security/res_users.xml",
"report/report_delivery_note.xml",
"views/account_move.xml",
"views/assets.xml",
"views/res_config_settings.xml",
"views/res_partner.xml",
"views/sale_order.xml",
Expand All @@ -43,4 +42,9 @@
"wizard/delivery_note_template.xml",
"wizard/sale_advance_payment_inv.xml",
],
"assets": {
"web.assets_common": [
"l10n_it_delivery_note/static/src/scss/stock_delivery_note.scss",
],
},
}

This file was deleted.

8 changes: 0 additions & 8 deletions l10n_it_delivery_note/migrations/13.0.1.0.0/post-migration.py

This file was deleted.

2 changes: 1 addition & 1 deletion l10n_it_delivery_note/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def is_pickings_related(self, picking_ids):
if self.is_delivery:
return self.delivery_picking_id in picking_ids

return bool(self.move_ids & picking_ids.mapped("move_lines"))
return bool(self.move_ids & picking_ids.mapped("move_ids"))

def retrieve_pickings_lines(self, picking_ids):
return self.filtered(lambda l: l.has_picking).filtered(
Expand Down
35 changes: 18 additions & 17 deletions l10n_it_delivery_note/models/stock_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def _domain_weight_uom(self):

active = fields.Boolean(default=True)
name = fields.Char(
string="Name",
readonly=True,
index=True,
copy=False,
Expand All @@ -95,7 +94,6 @@ def _domain_weight_uom(self):

state = fields.Selection(
DELIVERY_NOTE_STATES,
string="State",
copy=False,
default=DOMAIN_DELIVERY_NOTE_STATES[0],
required=True,
Expand All @@ -117,6 +115,7 @@ def _domain_weight_uom(self):
"res.partner",
string="Recipient",
states=DRAFT_EDITABLE_STATE,
default=_default_company,
readonly=True,
required=True,
index=True,
Expand All @@ -127,6 +126,7 @@ def _domain_weight_uom(self):
"res.partner",
string="Shipping address",
states=DONE_READONLY_STATE,
default=_default_company,
required=True,
tracking=True,
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
Expand All @@ -136,6 +136,7 @@ def _domain_weight_uom(self):
"res.partner",
string="Carrier",
states=DONE_READONLY_STATE,
default=_default_company,
tracking=True,
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
)
Expand All @@ -146,7 +147,7 @@ def _domain_weight_uom(self):
tracking=True,
)

date = fields.Date(string="Date", states=DRAFT_EDITABLE_STATE, copy=False)
date = fields.Date(states=DRAFT_EDITABLE_STATE, copy=False)
type_id = fields.Many2one(
"stock.delivery.note.type",
string="Type",
Expand All @@ -161,8 +162,8 @@ def _domain_weight_uom(self):
type_code = fields.Selection(
string="Type of Operation", related="type_id.code", store=True
)
packages = fields.Integer(string="Packages", states=DONE_READONLY_STATE)
volume = fields.Float(string="Volume", states=DONE_READONLY_STATE)
packages = fields.Integer(states=DONE_READONLY_STATE)
volume = fields.Float(states=DONE_READONLY_STATE)

volume_uom_id = fields.Many2one(
"uom.uom",
Expand Down Expand Up @@ -437,6 +438,7 @@ def check_compliance(self, pickings):
super().check_compliance(pickings)

self._check_delivery_notes(self.pickings_picker - self.picking_ids)
return True

def ensure_annulability(self):
if self.mapped("invoice_ids"):
Expand Down Expand Up @@ -473,7 +475,7 @@ def _fix_quantities_to_invoice(self, lines):
for line in other_lines:
cache[line] = line.fix_qty_to_invoice()

pickings_move_ids = self.mapped("picking_ids.move_lines")
pickings_move_ids = self.mapped("picking_ids.move_ids")
for line in pickings_lines.filtered(lambda l: len(l.move_ids) > 1):
move_ids = line.move_ids & pickings_move_ids
qty_to_invoice = sum(move_ids.mapped("quantity_done"))
Expand Down Expand Up @@ -511,7 +513,7 @@ def action_invoice(self):
for line, vals in cache.items():
line.write(vals)

orders_lines._get_to_invoice_qty()
orders_lines._compute_qty_to_invoice()

for line in self.line_ids:
line.write({"invoice_status": "invoiced"})
Expand Down Expand Up @@ -603,14 +605,13 @@ def update_detail_lines(self):
note._create_detail_lines(move_ids_to_create)
note._delete_detail_lines(move_ids_to_delete)

@api.model
def create(self, vals):
res = super().create(vals)

if "picking_ids" in vals:
res.update_detail_lines()

return res
@api.model_create_multi
def create(self, vals_list):
notes = super().create(vals_list)
for note in notes:
if note.picking_ids:
note.update_detail_lines()
return notes

def write(self, vals):
res = super().write(vals)
Expand Down Expand Up @@ -667,7 +668,7 @@ def _default_unit_uom(self):
readonly=True,
index=True,
)
sequence = fields.Integer(string="Sequence", required=True, default=10, index=True)
sequence = fields.Integer(required=True, default=10, index=True)
name = fields.Text(string="Description", required=True)
display_type = fields.Selection(
LINE_DISPLAY_TYPES, string="Line type", default=False
Expand All @@ -682,7 +683,7 @@ def _default_unit_uom(self):
currency_id = fields.Many2one(
"res.currency", string="Currency", required=True, default=_default_currency
)
discount = fields.Float(string="Discount", digits="Discount")
discount = fields.Float(digits="Discount")
tax_ids = fields.Many2many("account.tax", string="Taxes")

move_id = fields.Many2one(
Expand Down
5 changes: 3 additions & 2 deletions l10n_it_delivery_note/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def _add_delivery_cost_to_so(self):
super(
StockPicking, self.with_context(default_delivery_picking_id=self.id)
)._add_delivery_cost_to_so()
return True

def action_delivery_note_create(self):
self.ensure_one()
Expand Down Expand Up @@ -369,8 +370,8 @@ def _get_partners(self):
src_location_id = self.mapped("location_id")
dest_location_id = self.mapped("location_dest_id")

src_warehouse_id = src_location_id.get_warehouse()
dest_warehouse_id = dest_location_id.get_warehouse()
src_warehouse_id = src_location_id.warehouse_id
dest_warehouse_id = dest_location_id.warehouse_id

src_partner_id = src_warehouse_id.partner_id
dest_partner_id = dest_warehouse_id.partner_id
Expand Down
16 changes: 7 additions & 9 deletions l10n_it_delivery_note/security/res_users.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
<!--
Copyright (c) 2020, Link IT Europe srl, Italy. All rights reserved.
-->
<odoo>
<data noupdate="True">
<odoo noupdate="1">

<record id="base.user_root" model="res.users">
<field name="groups_id" eval="[(4, ref('can_change_number'))]" />
</record>
<record id="base.user_root" model="res.users">
<field name="groups_id" eval="[(4, ref('can_change_number'))]" />
</record>

<record id="base.user_admin" model="res.users">
<field name="groups_id" eval="[(4, ref('can_change_number'))]" />
</record>
<record id="base.user_admin" model="res.users">
<field name="groups_id" eval="[(4, ref('can_change_number'))]" />
</record>

</data>
</odoo>
8 changes: 4 additions & 4 deletions l10n_it_delivery_note/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>ITA - Documento di trasporto</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">ITA - Documento di trasporto</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_delivery_note"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_delivery_note"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/122/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_delivery_note"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_delivery_note"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/122/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><strong>English</strong></p>
<p>This module manage the Italian DDT (Delivery note).</p>
<p>From a picking is possible to generate a Delivery Note and group more picking in one delivery note. It’s also possible to invoice from the delivery note form.</p>
Expand Down Expand Up @@ -486,7 +486,7 @@ <h1><a class="toc-backref" href="#id6">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-italy/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_delivery_note%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_delivery_note%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -522,7 +522,7 @@ <h2><a class="toc-backref" href="#id10">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/As400it"><img alt="As400it" src="https://github.com/As400it.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_delivery_note">OCA/l10n-italy</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_delivery_note">OCA/l10n-italy</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions l10n_it_delivery_note/tests/test_stock_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ def test_partial_delivering_single_so(self):
sales_order.action_confirm()
self.assertEqual(len(sales_order.picking_ids), 1)
picking = sales_order.picking_ids
self.assertEqual(len(picking.move_lines), 2)
self.assertEqual(len(picking.move_ids), 2)

# deliver only the first product
picking.move_lines[0].quantity_done = 1
picking.move_ids[0].quantity_done = 1

res_dict = picking.button_validate()
wizard = Form(
self.env[(res_dict.get("res_model"))].with_context(res_dict["context"])
self.env[(res_dict.get("res_model"))].with_context(**res_dict["context"])
).save()
self.assertEqual(wizard._name, "stock.backorder.confirmation")
wizard.process()
self.assertTrue(picking.delivery_note_id)
picking_backorder = StockPicking.search([("backorder_id", "=", picking.id)])
self.assertEqual(len(picking_backorder.move_lines), 1)
picking_backorder.move_lines[0].quantity_done = 1
self.assertEqual(len(picking_backorder.move_ids), 1)
picking_backorder.move_ids[0].quantity_done = 1
picking_backorder.button_validate()
self.assertTrue(picking_backorder.delivery_note_id)

Expand Down Expand Up @@ -94,16 +94,16 @@ def test_delivery_without_so(self):
}
)

self.assertEqual(len(picking.move_lines), 1)
self.assertEqual(len(picking.move_ids), 1)

# deliver product
picking.move_lines.quantity_done = 1
picking.move_ids.quantity_done = 1
picking.button_validate()

# create delivery note with advanced mode
dn_form = Form(
self.env["stock.delivery.note.create.wizard"].with_context(
{"active_ids": [picking.id]}
active_ids=[picking.id]
)
)
dn = dn_form.save()
Expand Down
Loading

0 comments on commit abd4b01

Please sign in to comment.