Skip to content

Commit

Permalink
[IMP] l10n_it_delivery_note_order_link: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Apr 23, 2021
1 parent 7ae7af4 commit b68d2d0
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 68 deletions.
31 changes: 15 additions & 16 deletions l10n_it_delivery_note_order_link/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@

# noinspection PyStatementEffect
{
'name': 'ITA - Documento di trasporto - Collegamento con ordine di vendita',
'summary': 'Crea collegamento tra i DDT e ordine di vendita',
'author': 'Openindustry.it Sas, Odoo Community Association (OCA)',
'website': "https://github.com/OCA/l10n-italy/tree/12.0/"
"l10n_it_delivery_note_order_link",
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'maintainers': ['As400it', 'andreampiovesana'],
'category': 'Localization',
'depends': [
'purchase_stock',
'sale_stock',
'l10n_it_delivery_note',
"name": "ITA - Documento di trasporto - Collegamento con ordine di vendita",
"summary": "Crea collegamento tra i DDT e ordine di vendita",
"author": "Openindustry.it Sas, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-italy" "l10n_it_delivery_note_order_link",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"maintainers": ["As400it", "andreampiovesana"],
"category": "Localization",
"depends": [
"purchase_stock",
"sale_stock",
"l10n_it_delivery_note",
],
'data': [
'views/purchase_order.xml',
'views/sale_order.xml',
"data": [
"views/purchase_order.xml",
"views/sale_order.xml",
],
}
46 changes: 26 additions & 20 deletions l10n_it_delivery_note_order_link/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,55 @@


class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
_inherit = "purchase.order"

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

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

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

@api.multi
def goto_delivery_notes(self, **kwargs):
delivery_notes = self.mapped('delivery_note_ids')
delivery_notes = self.mapped("delivery_note_ids")
action = self.env.ref(
'l10n_it_delivery_note.stock_delivery_note_action').read()[0]
"l10n_it_delivery_note.stock_delivery_note_action"
).read()[0]
action.update(kwargs)

if len(delivery_notes) > 1:
action['domain'] = [('id', 'in', delivery_notes.ids)]
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
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'}
action = {"type": "ir.actions.act_window_close"}

return action


class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
_inherit = "purchase.order.line"

delivery_note_line_ids = fields.One2many('stock.delivery.note.line',
'purchase_line_id', readonly=True)
delivery_picking_id = fields.Many2one('stock.picking', readonly=True,
copy=False)
delivery_note_line_ids = fields.One2many(
"stock.delivery.note.line", "purchase_line_id", readonly=True
)
delivery_picking_id = fields.Many2one("stock.picking", readonly=True, copy=False)
12 changes: 7 additions & 5 deletions l10n_it_delivery_note_order_link/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@


class SaleOrder(models.Model):
_inherit = 'sale.order'
_inherit = "sale.order"

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

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

order.delivery_note_ids = delivery_notes
order.delivery_note_count = len(delivery_notes)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@


class StockDeliveryNoteLine(models.Model):
_inherit = 'stock.delivery.note.line'
_inherit = "stock.delivery.note.line"

purchase_line_id = fields.Many2one('purchase.order.line',
related='move_id.purchase_line_id',
store=True)
purchase_line_id = fields.Many2one(
"purchase.order.line", related="move_id.purchase_line_id", store=True
)
1 change: 0 additions & 1 deletion l10n_it_delivery_note_order_link/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ No configuration required after module installation.
**Italiano**

Dopo l'installazione del modulo non sono necessarie ulteriori configurazioni.

1 change: 0 additions & 1 deletion l10n_it_delivery_note_order_link/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ This module link delivery notes to purchase orders.
**Italiano**

Questo modulo consente di collegare gli ordini di acquisto ai DDT.

1 change: 0 additions & 1 deletion l10n_it_delivery_note_order_link/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ A smart button will appear on each purchase order, so you can link them to DNs.
**Italiano**

Su ciascun ordine di acquisto comparirà un pulsante (smart button) che permette di collegarlo ai DDT.

24 changes: 14 additions & 10 deletions l10n_it_delivery_note_order_link/views/purchase_order.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (c) 2019, Link IT Europe Srl
@author: Matteo Bilotta <mbilotta@linkeurope.it>
-->

<odoo>

<record id="purchase_order_form_view_delivery_note" model="ir.ui.view">
Expand All @@ -13,13 +11,19 @@
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button type="object"
class="oe_stat_button"
name="goto_delivery_notes"
icon="fa-pencil-square-o"
attrs="{'invisible': [('delivery_note_count', '=', 0)]}"
groups="l10n_it_delivery_note.use_advanced_delivery_notes">
<field name="delivery_note_count" widget="statinfo" string="Delivery Notes" />
<button
type="object"
class="oe_stat_button"
name="goto_delivery_notes"
icon="fa-pencil-square-o"
attrs="{'invisible': [('delivery_note_count', '=', 0)]}"
groups="l10n_it_delivery_note.use_advanced_delivery_notes"
>
<field
name="delivery_note_count"
widget="statinfo"
string="Delivery Notes"
/>
</button>
</xpath>
</field>
Expand Down
24 changes: 14 additions & 10 deletions l10n_it_delivery_note_order_link/views/sale_order.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (c) 2019, Link IT Europe Srl
@author: Matteo Bilotta <mbilotta@linkeurope.it>
-->

<odoo>

<record id="sale_order_form_view" model="ir.ui.view">
Expand All @@ -13,13 +11,19 @@
<field name="inherit_id" ref="sale_stock.view_order_form_inherit_sale_stock" />
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button type="object"
class="oe_stat_button"
name="goto_delivery_notes"
icon="fa-pencil-square-o"
attrs="{'invisible': [('delivery_note_count', '=', 0)]}"
groups="l10n_it_delivery_note.use_advanced_delivery_notes">
<field name="delivery_note_count" widget="statinfo" string="Delivery Notes" />
<button
type="object"
class="oe_stat_button"
name="goto_delivery_notes"
icon="fa-pencil-square-o"
attrs="{'invisible': [('delivery_note_count', '=', 0)]}"
groups="l10n_it_delivery_note.use_advanced_delivery_notes"
>
<field
name="delivery_note_count"
widget="statinfo"
string="Delivery Notes"
/>
</button>
</xpath>
</field>
Expand Down
6 changes: 6 additions & 0 deletions setup/l10n_it_delivery_note_order_link/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit b68d2d0

Please sign in to comment.