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

[BP]stock_landed_costs_ux: backport in 16.0 #601

Closed
wants to merge 1 commit into from
Closed
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
70 changes: 70 additions & 0 deletions stock_landed_costs_ux/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.. |company| replace:: ADHOC SA

.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png
:alt: ADHOC SA
:target: https://www.adhoc.com.ar

.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=====================
Stock Landed Costs UX
=====================

#. Changes the method of the creation of the landed costs in the account move, by using the currency rate defined in the account move.

Installation
============

To install this module, you need to:

#. Only need to install the module

Configuration
=============

To configure this module, you need to:

#. Install

Usage
=====

To use this module, you need to:

#. Go to ...

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/

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

Bugs are tracked on `GitHub Issues
<https://github.com/ingadhoc/stock/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.

Credits
=======

Images
------

* |company| |icon|

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

Maintainer
----------

|company_logo|

This module is maintained by the |company|.

To contribute to this module, please visit https://www.adhoc.com.ar.
4 changes: 4 additions & 0 deletions stock_landed_costs_ux/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import models
40 changes: 40 additions & 0 deletions stock_landed_costs_ux/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
##############################################################################
#
# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar)
# All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Stock Landed Costs UX',
'version': "16.0.1.0.0",
'category': 'Warehouse Management',
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'images': [
],
'depends': [
'stock_landed_costs',
'l10n_ar_ux',
],
'data': [
],
'installable': True,
'auto_install': True,
'application': False,
'license': 'AGPL-3',
}
25 changes: 25 additions & 0 deletions stock_landed_costs_ux/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_landed_costs_ux
#
# Translators:
# Juan José Scarafía <[email protected]>, 2024
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-06 14:14+0000\n"
"PO-Revision-Date: 2024-12-06 14:14+0000\n"
"Last-Translator: Juan José Scarafía <[email protected]>, 2024\n"
"Language-Team: Spanish (https://app.transifex.com/adhoc/teams/46451/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n"

#. module: stock_landed_costs_ux
#: model:ir.model,name:stock_landed_costs_ux.model_account_move
msgid "Journal Entry"
msgstr "Asiento contable"
4 changes: 4 additions & 0 deletions stock_landed_costs_ux/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import account_move
41 changes: 41 additions & 0 deletions stock_landed_costs_ux/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, fields, models


class AccountMove(models.Model):
_inherit = 'account.move'

def button_create_landed_costs(self):
"""Modifies the original method changing the price_unit of the landed_costs
If the account.move has a different currency change from the one defined in the company,
takes this one to calculate the price_unit
"""
self.ensure_one()
landed_costs_lines = self.line_ids.filtered(lambda line: line.is_landed_costs_line)
rate_to_use = self.l10n_ar_currency_rate if self.l10n_ar_currency_rate else None
landed_costs = self.env['stock.landed.cost'].with_company(self.company_id).create({
'vendor_bill_id': self.id,
'cost_lines': [(0, 0, {
'product_id': l.product_id.id,
'name': l.product_id.name,
'account_id': l.product_id.product_tmpl_id.get_product_accounts()['stock_input'].id,
'price_unit': self._compute_price_unit(l, rate_to_use),
'split_method': l.product_id.split_method_landed_cost or 'equal',
}) for l in landed_costs_lines],
})
action = self.env["ir.actions.actions"]._for_xml_id("stock_landed_costs.action_stock_landed_cost")
return dict(action, view_mode='form', res_id=landed_costs.id, views=[(False, 'form')])

def _compute_price_unit(self, landed_cost_line, rate_to_use):
"""Calculates the price_unit using the corresponding currency rate"""
if rate_to_use:
return landed_cost_line.price_subtotal * rate_to_use
else:
return landed_cost_line.currency_id._convert(
landed_cost_line.price_subtotal,
landed_cost_line.company_currency_id,
landed_cost_line.company_id,
self.invoice_date or fields.Date.context_today(self)
)