Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][ADD] stock_move_sale_line_description: Show sale order line de… #3017

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/stock_move_sale_line_description/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,
)
28 changes: 28 additions & 0 deletions stock_move_sale_line_description/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

================================
Stock Move Sale Line Description
================================

* Show sale order line description in stock move.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted
it first, help us smash it by providing detailed and welcomed feedback.

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

Credits
=======

Contributors
------------

* Ana Juaristi <[email protected]>
* Alfredo de la Fuente <[email protected]>
1 change: 1 addition & 0 deletions stock_move_sale_line_description/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions stock_move_sale_line_description/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Stock Move Sale Line Description",
"version": "14.0.1.0.0",
"author": "Avanzosc",
"category": "Sale",
"website": "https://github.com/avanzosc/odoo-addons",
"depends": [
"sale",
"stock",
],
"data": [
"report/report_deliveryslip.xml",
"views/stock_picking_view.xml",
],
"license": "AGPL-3",
"installable": True,
}
44 changes: 44 additions & 0 deletions stock_move_sale_line_description/i18n/en_GB.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_move_sale_line_description
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-27 10:13+0000\n"
"PO-Revision-Date: 2024-11-27 10:13+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line__display_name
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move__display_name
msgid "Display Name"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line__id
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move__id
msgid "ID"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line____last_update
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move____last_update
msgid "Last Modified on"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model,name:stock_move_sale_line_description.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model,name:stock_move_sale_line_description.model_stock_move
msgid "Stock Move"
msgstr ""
44 changes: 44 additions & 0 deletions stock_move_sale_line_description/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_move_sale_line_description
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-27 10:13+0000\n"
"PO-Revision-Date: 2024-11-27 10:13+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line__display_name
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line__id
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move__id
msgid "ID"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line____last_update
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move____last_update
msgid "Last Modified on"
msgstr "Última modificación el"

#. module: stock_move_sale_line_description
#: model:ir.model,name:stock_move_sale_line_description.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línea de pedido de venta"

#. module: stock_move_sale_line_description
#: model:ir.model,name:stock_move_sale_line_description.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de existencias"
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_move_sale_line_description
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-27 10:12+0000\n"
"PO-Revision-Date: 2024-11-27 10:12+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line__display_name
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move__display_name
msgid "Display Name"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line__id
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move__id
msgid "ID"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_sale_order_line____last_update
#: model:ir.model.fields,field_description:stock_move_sale_line_description.field_stock_move____last_update
msgid "Last Modified on"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model,name:stock_move_sale_line_description.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: stock_move_sale_line_description
#: model:ir.model,name:stock_move_sale_line_description.model_stock_move
msgid "Stock Move"
msgstr ""
2 changes: 2 additions & 0 deletions stock_move_sale_line_description/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_move
from . import sale_order_line
15 changes: 15 additions & 0 deletions stock_move_sale_line_description/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def write(self, values):
result = super(SaleOrderLine, self).write(values)
if "name" in values:
for line in self:
if line.move_ids:
line.move_ids.write({"name": line.name})
return result
20 changes: 20 additions & 0 deletions stock_move_sale_line_description/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models


class StockMove(models.Model):
_inherit = "stock.move"

@api.onchange("sale_line_id")
def compute_stock_move_description(self):
for record in self:
if record.sale_line_id:
record.name = record.sale_line_id.name

@api.model
def create(self, vals):
res = super().create(vals)
if res.sale_line_id:
res.compute_stock_move_description()
return res
52 changes: 52 additions & 0 deletions stock_move_sale_line_description/report/report_deliveryslip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template
id="stock_report_delivery_has_serial_move_line"
inherit_id="stock.stock_report_delivery_has_serial_move_line"
priority="100"
>
<xpath expr="//td[1]" position="replace">
<td t-if="show_description">
<span t-field="move_line.move_id.name" />
</td>
<t t-else="">
<td>
<span t-field="move_line.product_id" />
<!-- this is an annoying workaround for the multiple types of descriptions (often auto-filled) that we do not want to print -->
<!-- this makes it so we can pre-filter the descriptions in inherited templates since we cannot extend the standard "if" condition -->
<!-- let's agree that pre-filtered descriptions will be set to "" -->
<t t-if="not description and description != ''">
<t
t-set="description"
t-value="move_line.move_id.description_picking"
/>
</t>
<p
t-if="description !='' and description != move_line.product_id.name"
>
<span t-esc="description" />
</p>
</td>
</t>
</xpath>
</template>
<template
id="report_delivery_document"
inherit_id="stock.report_delivery_document"
priority="100"
>
<xpath
expr="//table[@name='stock_move_table']/tbody/tr[@t-foreach='lines']/td[1]"
position="replace"
>
<td>
<span t-field="move.name" />
</td>
</xpath>
</template>
<template id="report_deliveryslip" inherit_id="stock.report_deliveryslip">
<xpath expr="//t[@t-call='stock.report_delivery_document']" position="before">
<t t-set="show_description" t-value="1" />
</xpath>
</template>
</odoo>
15 changes: 15 additions & 0 deletions stock_move_sale_line_description/views/stock_picking_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_picking_form" model="ir.ui.view">
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='move_ids_without_package']/tree/field[@name='product_id']"
position="after"
>
<field name="name" />
</xpath>
</field>
</record>
</odoo>
Loading