Compare commits
2 Commits
14.0-sale_
...
14.0-add-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7172a5c7f | ||
|
|
5023839119 |
@@ -43,6 +43,13 @@ class AccountBankStatement(models.Model):
|
||||
res.append((statement.id, name))
|
||||
return res
|
||||
|
||||
def button_reopen(self):
|
||||
self = self.with_context(skip_undo_reconciliation=True)
|
||||
return super().button_reopen()
|
||||
|
||||
def button_undo_reconciliation(self):
|
||||
self.line_ids.button_undo_reconciliation()
|
||||
|
||||
|
||||
class AccountBankStatementLine(models.Model):
|
||||
_inherit = 'account.bank.statement.line'
|
||||
@@ -89,3 +96,9 @@ class AccountBankStatementLine(models.Model):
|
||||
'res_id': self.move_id.id,
|
||||
})
|
||||
return action
|
||||
|
||||
def button_undo_reconciliation(self):
|
||||
if self._context.get("skip_undo_reconciliation"):
|
||||
return
|
||||
else:
|
||||
return super().button_undo_reconciliation()
|
||||
|
||||
@@ -10,8 +10,6 @@ from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.osv import expression
|
||||
from odoo.tools import float_is_zero
|
||||
from odoo.tools.misc import format_date
|
||||
from odoo.tools.safe_eval import safe_eval, time
|
||||
from collections import defaultdict
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -52,37 +50,6 @@ class AccountMove(models.Model):
|
||||
string="Dispute",
|
||||
tracking=True,
|
||||
)
|
||||
# Having amounts in invoice currency can be useful in tree view of invoices
|
||||
# We add those fields with optional="hide"
|
||||
amount_untaxed_invoice_currency_signed = fields.Monetary(
|
||||
compute="_compute_amount_invoice_currency_signed", store=True,
|
||||
string="Untaxed Amount Invoice Currency Signed")
|
||||
amount_tax_invoice_currency_signed = fields.Monetary(
|
||||
compute="_compute_amount_invoice_currency_signed", store=True,
|
||||
string="Tax Invoice Currency Signed")
|
||||
amount_total_invoice_currency_signed = fields.Monetary(
|
||||
compute="_compute_amount_invoice_currency_signed", store=True,
|
||||
string="Total Invoice Currency Signed")
|
||||
amount_residual_invoice_currency_signed = fields.Monetary(
|
||||
compute="_compute_amount_invoice_currency_signed", store=True,
|
||||
string="Amount Due Invoice Currency Signed")
|
||||
|
||||
@api.depends('amount_untaxed', 'amount_tax', 'amount_total', 'amount_residual', 'move_type')
|
||||
def _compute_amount_invoice_currency_signed(self):
|
||||
for move in self:
|
||||
amount_untaxed_invoice_currency_signed = move.amount_untaxed
|
||||
amount_tax_invoice_currency_signed = move.amount_tax
|
||||
amount_total_invoice_currency_signed = move.amount_total
|
||||
amount_residual_invoice_currency_signed = move.amount_residual
|
||||
if move.move_type in ('out_refund', 'in_refund'):
|
||||
amount_untaxed_invoice_currency_signed *= -1
|
||||
amount_tax_invoice_currency_signed *= -1
|
||||
amount_total_invoice_currency_signed *= -1
|
||||
amount_residual_invoice_currency_signed *= -1
|
||||
move.amount_untaxed_invoice_currency_signed = amount_untaxed_invoice_currency_signed
|
||||
move.amount_tax_invoice_currency_signed = amount_tax_invoice_currency_signed
|
||||
move.amount_total_invoice_currency_signed = amount_total_invoice_currency_signed
|
||||
move.amount_residual_invoice_currency_signed = amount_residual_invoice_currency_signed
|
||||
|
||||
@api.depends("line_ids", "line_ids.blocked")
|
||||
def _compute_blocked(self):
|
||||
@@ -256,11 +223,13 @@ class AccountMove(models.Model):
|
||||
move.suitable_journal_ids = self.env['account.journal'].search(domain)
|
||||
|
||||
def button_draft(self):
|
||||
# Get report name before reset to draft because name can be different.
|
||||
report_names = self._get_invoice_attachment_name()
|
||||
super().button_draft()
|
||||
# Delete attached pdf invoice
|
||||
if report_names:
|
||||
try:
|
||||
report_invoice = self.env['ir.actions.report']._get_report_from_name('account.report_invoice')
|
||||
except IndexError:
|
||||
report_invoice = False
|
||||
if report_invoice and report_invoice.attachment:
|
||||
for move in self.filtered(lambda x: x.move_type in ('out_invoice', 'out_refund')):
|
||||
# The pb is that the filename is dynamic and related to move.state
|
||||
# in v12, the feature was native and they used that kind of code:
|
||||
@@ -270,7 +239,7 @@ class AccountMove(models.Model):
|
||||
# But do_in_draft() doesn't exists in v14
|
||||
# If you know how we could do that, please update the code below
|
||||
attachment = self.env['ir.attachment'].search([
|
||||
('name', 'in', report_names[move.id]),
|
||||
('name', '=', self._get_invoice_attachment_name()),
|
||||
('res_id', '=', move.id),
|
||||
('res_model', '=', self._name),
|
||||
('type', '=', 'binary'),
|
||||
@@ -279,22 +248,8 @@ class AccountMove(models.Model):
|
||||
attachment.unlink()
|
||||
|
||||
def _get_invoice_attachment_name(self):
|
||||
report_names = defaultdict(list)
|
||||
try:
|
||||
report_invoice = self.env['ir.actions.report']._get_report_from_name('account.report_invoice')
|
||||
except IndexError:
|
||||
report_invoice = False
|
||||
if report_invoice and report_invoice.attachment:
|
||||
for move in self.filtered(lambda x: x.move_type in ('out_invoice', 'out_refund')):
|
||||
report_names[move.id].append(safe_eval(report_invoice.print_report_name, {'object': self, 'time': time}))
|
||||
try:
|
||||
report_invoice = self.env['ir.actions.report']._get_report_from_name('account.report_invoice_with_payments')
|
||||
except IndexError:
|
||||
report_invoice = False
|
||||
if report_invoice and report_invoice.attachment:
|
||||
for move in self.filtered(lambda x: x.move_type in ('out_invoice', 'out_refund')):
|
||||
report_names[move.id].append(safe_eval(report_invoice.print_report_name, {'object': self, 'time': time}))
|
||||
return report_names
|
||||
self.ensure_one()
|
||||
return '%s.pdf' % (self.name and self.name.replace('/', '_') or 'INV')
|
||||
|
||||
def _get_accounting_date(self, invoice_date, has_tax):
|
||||
# On vendor bills/refunds, we want date = invoice_date unless
|
||||
|
||||
@@ -16,6 +16,14 @@
|
||||
<button name="button_reopen" position="attributes">
|
||||
<attribute name="confirm">Are you sure ? Don't do 'Reset to New' if you just want to modify the bank journal entry of an existing statement line.</attribute>
|
||||
</button>
|
||||
<button name="button_reopen" position="after">
|
||||
<button
|
||||
name="button_undo_reconciliation"
|
||||
type="object"
|
||||
confirm="Are you sure to unreconcile all the entries of the bank statement?"
|
||||
states="open"
|
||||
string="Unreconcile All"/>
|
||||
</button>
|
||||
<xpath expr="//field[@name='line_ids']/tree/button[@name='button_undo_reconciliation']" position="after">
|
||||
<field name="move_id" invisible="1"/>
|
||||
<button name="show_account_move" type="object"
|
||||
|
||||
@@ -67,14 +67,6 @@
|
||||
<field name="amount_residual_signed" position="attributes">
|
||||
<attribute name="optional">show</attribute>
|
||||
</field>
|
||||
<field name="amount_untaxed_signed" position="before">
|
||||
<!-- No sum="1" on the invoice currency fields, because it doesn't make sense
|
||||
to add amounts in different currencies -->
|
||||
<field name="amount_untaxed_invoice_currency_signed" string="Tax Excluded Inv. Cur." optional="hide"/>
|
||||
<field name="amount_tax_invoice_currency_signed" string="Tax Inv. Cur." optional="hide"/>
|
||||
<field name="amount_total_invoice_currency_signed" string="Total Inv. Cur." optional="hide"/>
|
||||
<field name="amount_residual_invoice_currency_signed" string="Amount Due Inv. Cur." optional="hide"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'depends': ['delivery'],
|
||||
'data': [
|
||||
'views/stock_picking.xml',
|
||||
'views/product_packaging.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
from . import product_packaging
|
||||
from . import stock_picking
|
||||
from . import stock_move
|
||||
from . import stock_quant_package
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# Copyright 2018-2021 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductPackaging(models.Model):
|
||||
_inherit = 'product.packaging'
|
||||
|
||||
# product.packaging is defined in the 'product' module and enhanced in the 'delivery' module
|
||||
# I used to make the improvements on the datamodel of product.packaging in the OCA module
|
||||
# 'stock_packaging_usability_pp' from OCA/stock-logistics-tracking,
|
||||
# but I eventually figured out that the feature provided by 'stock_packaging_usability_pp'
|
||||
# was native in the 'delivery' module via the wizard choose.delivery.package.
|
||||
# So I stopped using 'stock_packaging_usability_pp' and I moved the datamodel changes
|
||||
# here in the module 'delivery_usability'
|
||||
name = fields.Char(translate=True)
|
||||
weight = fields.Float(digits="Stock Weight", string="Empty Package Weight")
|
||||
active = fields.Boolean(default=True)
|
||||
# packaging_type is important, in particular for pallets for which
|
||||
# we need a special implementation to enter the height
|
||||
packaging_type = fields.Selection(
|
||||
[
|
||||
("unit", "Unit"),
|
||||
("pack", "Pack"),
|
||||
("box", "Box"),
|
||||
("pallet", "Pallet"),
|
||||
],
|
||||
string="Type",
|
||||
)
|
||||
@@ -1,23 +0,0 @@
|
||||
# Copyright 2019 Akretion France (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class StockMove(models.Model):
|
||||
_inherit = "stock.move"
|
||||
|
||||
# Fixing bug https://github.com/odoo/odoo/issues/34702
|
||||
@api.depends("product_id", "product_uom_qty", "product_uom")
|
||||
def _cal_move_weight(self):
|
||||
weight_uom_categ = self.env.ref("uom.product_uom_categ_kgm")
|
||||
kg_uom = self.env.ref("uom.product_uom_kgm")
|
||||
for move in self:
|
||||
if move.product_id.uom_id.category_id == weight_uom_categ:
|
||||
move.weight = move.product_id.uom_id._compute_quantity(
|
||||
move.product_qty, kg_uom
|
||||
)
|
||||
else:
|
||||
move.weight = move.product_qty * move.product_id.weight
|
||||
@@ -1,68 +0,0 @@
|
||||
# Copyright 2019-2024 Akretion France (https://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo.tools import float_is_zero
|
||||
|
||||
|
||||
class StockQuantPackage(models.Model):
|
||||
_inherit = "stock.quant.package"
|
||||
|
||||
# These 2 fields are defined in the 'delivery' module but they forgot
|
||||
# the decimal precision
|
||||
shipping_weight = fields.Float(digits="Stock Weight")
|
||||
weight = fields.Float(digits="Stock Weight")
|
||||
|
||||
# Fixing bug https://github.com/odoo/odoo/issues/34702
|
||||
# and take into account the weight of the packaging
|
||||
# WARNING: this method _compute_weight() is also inherited by the OCA module
|
||||
# base_delivery_carrier_label so if you use that module, you should copy
|
||||
# that piece of code in a custom module that depend on delivery_usability
|
||||
# and base_delivery_carrier_label
|
||||
def _compute_weight(self):
|
||||
smlo = self.env["stock.move.line"]
|
||||
weight_uom_categ = self.env.ref("uom.product_uom_categ_kgm")
|
||||
kg_uom = self.env.ref("uom.product_uom_kgm")
|
||||
weight_prec = self.env['decimal.precision'].precision_get('Stock Weight')
|
||||
for package in self:
|
||||
# if the weight of the package has been measured,
|
||||
# it is written in shipping_weight
|
||||
if not float_is_zero(package.shipping_weight, precision_digits=weight_prec):
|
||||
weight = package.shipping_weight
|
||||
# otherwise, we compute the theorical weight from the weight of the products
|
||||
# and the weight of the packaging
|
||||
# Since Odoo v11, consu products don't create quants, so I can't loop
|
||||
# on pack.quant_ids to get all the items inside a package: I have to
|
||||
# get the picking, then loop on the stock.move.line of that picking
|
||||
# linked to that package
|
||||
else:
|
||||
weight = 0.0
|
||||
# the package can be seen in a return
|
||||
# So I get the picking of it's first appearance
|
||||
domain = [
|
||||
("result_package_id", "=", package.id),
|
||||
("product_id", "!=", False),
|
||||
]
|
||||
first_move_line = smlo.search(
|
||||
domain + [('picking_id', '!=', False)], limit=1, order='id')
|
||||
if first_move_line:
|
||||
picking_id = first_move_line.picking_id.id
|
||||
current_picking_move_line_ids = smlo.search(
|
||||
domain + [("picking_id", "=", picking_id)])
|
||||
for ml in current_picking_move_line_ids:
|
||||
if ml.product_uom_id.category_id == weight_uom_categ:
|
||||
weight += ml.product_uom_id._compute_quantity(
|
||||
ml.qty_done, kg_uom
|
||||
)
|
||||
else:
|
||||
weight += (
|
||||
ml.product_uom_id._compute_quantity(
|
||||
ml.qty_done, ml.product_id.uom_id
|
||||
)
|
||||
* ml.product_id.weight
|
||||
)
|
||||
if package.packaging_id:
|
||||
weight += package.packaging_id.weight
|
||||
package.weight = weight
|
||||
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2019-2024 Akretion France (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
<odoo>
|
||||
|
||||
|
||||
<!-- I don't know why the form view of product.packaging in the delivery
|
||||
module has "<field name="inherit_id" eval="False"/>"
|
||||
instead of a standard inherit of product.product_packaging_form_view -->
|
||||
<record id="product_packaging_delivery_form" model="ir.ui.view">
|
||||
<field name="name">stock_packaging_usability_pp.product.packaging.form</field>
|
||||
<field name="model">product.packaging</field>
|
||||
<field name="inherit_id" ref="delivery.product_packaging_delivery_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="package_carrier_type" position="after">
|
||||
<field name="packaging_type" />
|
||||
<field name="active" invisible="1" />
|
||||
</field>
|
||||
<label for="max_weight" position="before">
|
||||
<label for="weight" />
|
||||
<div class="o_row" name="weight">
|
||||
<field name="weight" />
|
||||
<span><field name="weight_uom_name" /></span>
|
||||
</div>
|
||||
</label>
|
||||
<label for="name" position="before">
|
||||
<widget
|
||||
name="web_ribbon"
|
||||
title="Archived"
|
||||
bg_color="bg-danger"
|
||||
attrs="{'invisible': [('active', '=', True)]}"
|
||||
/>
|
||||
</label>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_packaging_delivery_tree" model="ir.ui.view">
|
||||
<field name="name">stock_packaging_usability_pp.product.packaging.tree</field>
|
||||
<field name="model">product.packaging</field>
|
||||
<field name="inherit_id" ref="delivery.product_packaging_delivery_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="after">
|
||||
<field name="packaging_type" optional="show" />
|
||||
</field>
|
||||
<field name="max_weight" position="before">
|
||||
<field name="weight" optional="show" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- There is no native serch view for product.packaging -->
|
||||
<record id="product_packaging_search" model="ir.ui.view">
|
||||
<field name="name">product.packaging.search</field>
|
||||
<field name="model">product.packaging</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name" />
|
||||
<separator />
|
||||
<filter
|
||||
string="Archived"
|
||||
name="inactive"
|
||||
domain="[('active', '=', False)]"
|
||||
/>
|
||||
<group name="groupby">
|
||||
<filter
|
||||
name="packaging_type_groupby"
|
||||
string="Packaging Type"
|
||||
context="{'group_by': 'packaging_type'}"
|
||||
/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
@@ -1 +0,0 @@
|
||||
from . import models
|
||||
@@ -1,24 +0,0 @@
|
||||
# Copyright 2024 Akretion (https://www.akretion.com).
|
||||
# @author Mathieu DELVA <mathieu.delva@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
{
|
||||
"name": "sale_order_line_date_next_reception",
|
||||
"summary": "Next reception Date on sale order line",
|
||||
"version": "14.0.1.0.0",
|
||||
"category": "Sale",
|
||||
"author": "Akretion",
|
||||
"website": "https://github.com/akretion/odoo-usability",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"sale",
|
||||
"purchase",
|
||||
"stock"
|
||||
],
|
||||
"data": [
|
||||
"views/sale_order_view.xml",
|
||||
],
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
from . import sale_order_line
|
||||
@@ -1,24 +0,0 @@
|
||||
# Copyright 2024 Akretion (http://www.akretion.com).
|
||||
# @author Mathieu DELVA <mathieu.delva@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
date_next_reception = fields.Date(compute="_compute_date_next_reception", compute_sudo=True)
|
||||
|
||||
def _compute_date_next_reception(self):
|
||||
for line in self:
|
||||
line.date_next_reception = False
|
||||
qty_available = line.product_id.with_context(warehouse=line.order_id.warehouse_id.id).qty_available
|
||||
if qty_available <=0 and line.state not in ['done', 'cancel']:
|
||||
picking_model = self.env["stock.picking"]
|
||||
picking_id = picking_model.search([
|
||||
('product_id', '=', line.product_id.id),
|
||||
("picking_type_id.code", "=", "incoming"),
|
||||
('state', 'in', ['ready', 'waiting', 'assigned'])
|
||||
])
|
||||
line.date_next_reception = picking_id and picking_id[0].scheduled_date.date()
|
||||
@@ -1 +0,0 @@
|
||||
* Mathieu Delva <mathieu.delva@akretion.com>
|
||||
@@ -1 +0,0 @@
|
||||
This module displays the date of receipt of the product on the sale order line when the product is no longer in stock and there is a purchase in progress
|
||||
@@ -1,2 +0,0 @@
|
||||
# from . import test_sale_line_number
|
||||
from . import test_sale_line_reception_date
|
||||
@@ -1,58 +0,0 @@
|
||||
# Copyright 2024 Akretion (http://www.akretion.com).
|
||||
# @author Mathieu DELVA <mathieu.delva@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
|
||||
class TestSaleLineReceptionDate(TransactionCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.partner = self.env.ref("base.res_partner_12")
|
||||
self.product_id = self.env.ref("product.product_product_5")
|
||||
|
||||
self.purchase_order = self.env["purchase.order"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"date_order": datetime.today() + relativedelta(days=10),
|
||||
"order_line": [(0, 0, {
|
||||
"product_id": self.product_id.id,
|
||||
"product_qty": 5,
|
||||
})]
|
||||
})
|
||||
|
||||
def test_date_next_reception(self):
|
||||
self.purchase_order.button_confirm()
|
||||
self.sale_order = self.env["sale.order"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"order_line": [(0, 0, {
|
||||
"product_id": self.product_id.id,
|
||||
"product_uom_qty": 2
|
||||
})]
|
||||
})
|
||||
self.assertEqual(self.purchase_order.date_planned.date(), self.sale_order.order_line.date_next_reception)
|
||||
|
||||
def test_2_date_next_reception(self):
|
||||
self.purchase_order.button_confirm()
|
||||
self.purchase_order2 = self.env["purchase.order"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"date_order": datetime.today() + relativedelta(days=4),
|
||||
"order_line": [(0, 0, {
|
||||
"product_id": self.product_id.id,
|
||||
"product_qty": 5,
|
||||
})]
|
||||
})
|
||||
self.sale_order = self.env["sale.order"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"order_line": [(0, 0, {
|
||||
"product_id": self.product_id.id,
|
||||
"product_uom_qty": 2
|
||||
})]
|
||||
})
|
||||
self.purchase_order2.button_confirm()
|
||||
self.assertEqual(self.purchase_order2.date_planned.date(), self.sale_order.order_line.date_next_reception)
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="sale_order_view_form" model="ir.ui.view">
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath
|
||||
expr="//field[@name='order_line']/tree/field[@name='price_unit']"
|
||||
position="before"
|
||||
>
|
||||
<field name="date_next_reception" optional="hide"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -27,7 +27,6 @@
|
||||
<field name="client_order_ref"/>
|
||||
</field>
|
||||
<button name="action_quotation_send" states="sent,sale" position="after">
|
||||
<button name="action_quotation_send" type="object" string="Send Order Acknowledgement" attrs="{'invisible': ['|', ('state', 'not in', ('sale', 'done')), ('invoice_count','>=',1)]}"/>
|
||||
<button name="%(sale.action_report_saleorder)d" type="action" string="Print" states="draft,sent,sale,done"/>
|
||||
</button>
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='product_template_id']" position="after">
|
||||
|
||||
2
stock_location_simple/__init__.py
Normal file
2
stock_location_simple/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import models
|
||||
from .hooks import post_init_hook
|
||||
14
stock_location_simple/__manifest__.py
Normal file
14
stock_location_simple/__manifest__.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# Copyright 2024 Akretion
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "Stock Location Simple",
|
||||
"summary": "Simplified stock.location menu",
|
||||
"version": "14.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "Akretion",
|
||||
"website": "http://akretion.com",
|
||||
"depends": ["stock"],
|
||||
"data": ["views/stock_location_views.xml"],
|
||||
"post_init_hook": "post_init_hook",
|
||||
}
|
||||
10
stock_location_simple/hooks.py
Normal file
10
stock_location_simple/hooks.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# Copyright 2021 Akretion (https://www.akretion.com).
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
env["stock.warehouse"].search([])._check_locations_created_by_warehouse()
|
||||
2
stock_location_simple/models/__init__.py
Normal file
2
stock_location_simple/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import stock_location
|
||||
from . import stock_warehouse
|
||||
10
stock_location_simple/models/stock_location.py
Normal file
10
stock_location_simple/models/stock_location.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# Copyright 2024 Akretion
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
class StockLocation(models.Model):
|
||||
_inherit = "stock.location"
|
||||
|
||||
is_created_by_warehouse = fields.Boolean()
|
||||
34
stock_location_simple/models/stock_warehouse.py
Normal file
34
stock_location_simple/models/stock_warehouse.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Copyright 2024 Akretion
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
import pprint
|
||||
|
||||
|
||||
class StockWarehouse(models.Model):
|
||||
_inherit = "stock.warehouse"
|
||||
|
||||
def _get_location_fields(self):
|
||||
location_fields = []
|
||||
|
||||
for field, definition in self.fields_get().items():
|
||||
if definition.get("relation") == "stock.location":
|
||||
location_fields.append(field)
|
||||
|
||||
return location_fields
|
||||
|
||||
def _check_locations_created_by_warehouse(self):
|
||||
location_ids = self.env["stock.location"]
|
||||
location_fields = self._get_location_fields()
|
||||
|
||||
for rec in self:
|
||||
for field in location_fields:
|
||||
location_ids |= getattr(rec, field)
|
||||
|
||||
location_ids.write({"is_created_by_warehouse": True})
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super().create(vals)
|
||||
res._check_locations_created_by_warehouse()
|
||||
return res
|
||||
1
stock_location_simple/tests/__init__.py
Normal file
1
stock_location_simple/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_stock_location_simple
|
||||
19
stock_location_simple/tests/test_stock_location_simple.py
Normal file
19
stock_location_simple/tests/test_stock_location_simple.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Copyright 2018-2022 Camptocamp
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests import TransactionCase
|
||||
|
||||
|
||||
class TestStockLocationSimple(TransactionCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.env["stock.warehouse"].search([])._check_locations_created_by_warehouse()
|
||||
|
||||
def test_location_checked_at_warehouse_creation(self):
|
||||
warehouse = self.env["stock.warehouse"].create({"name": "Test", "code": "TEST"})
|
||||
self.assertTrue(warehouse.view_location_id.is_created_by_warehouse)
|
||||
|
||||
def test_native_location_checked(self):
|
||||
location_id = self.env.ref("stock.warehouse0").view_location_id
|
||||
|
||||
self.assertTrue(location_id.is_created_by_warehouse)
|
||||
90
stock_location_simple/views/stock_location_views.xml
Normal file
90
stock_location_simple/views/stock_location_views.xml
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2024 Akretion
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="stock_location_simple_form_view" model="ir.ui.view">
|
||||
<field name="name">stock.location.simple.form</field>
|
||||
<field name="model">stock.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Stock Location">
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button string="Current Stock"
|
||||
class="oe_stat_button"
|
||||
icon="fa-cubes" name="%(stock.location_open_quants)d" type="action"/>
|
||||
</div>
|
||||
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1>
|
||||
<field name="name"/>
|
||||
</h1>
|
||||
<label for="location_id" class="oe_edit_only"/>
|
||||
<h2>
|
||||
<field name="location_id" required="1" domain="[('usage', '=', 'internal')]"/>
|
||||
</h2>
|
||||
|
||||
<group>
|
||||
<field name="active" invisible="1"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
|
||||
<field name="comment" placeholder="External note..."/>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_location_simple_tree_view" model="ir.ui.view">
|
||||
<field name="name">stock.location.simple.tree</field>
|
||||
<field name="model">stock.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<!-- TODO: decoration info if lockdown, if view, if linked to a warehouse -->
|
||||
<tree string="Stock Location">
|
||||
<field name="active" invisible="1"/>
|
||||
<field name="complete_name" string="Location"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_location_simple_act_window" model="ir.actions.act_window">
|
||||
<field name="name">Stock Location</field>
|
||||
<field name="res_model">stock.location</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[("usage", "=", "internal")]</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_location_simple_act_window_tree" model="ir.actions.act_window.view" >
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="stock_location_simple_tree_view"/>
|
||||
<field name="act_window_id" ref="stock_location_simple_act_window"/>
|
||||
</record>
|
||||
|
||||
<record id="stock_location_simple_act_window_form" model="ir.actions.act_window.view" >
|
||||
<field name="sequence" eval="3"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="stock_location_simple_form_view"/>
|
||||
<field name="act_window_id" ref="stock_location_simple_act_window"/>
|
||||
</record>
|
||||
|
||||
<record id="stock_location_simple_menu" model="ir.ui.menu">
|
||||
<field name="name">Locations</field>
|
||||
<field name="parent_id" ref="stock.menu_warehouse_config"/>
|
||||
<field name="action" ref="stock_location_simple_act_window"/>
|
||||
<field name="sequence" eval="0"/>
|
||||
<field name="groups_id" eval="[(4, ref('stock.group_stock_multi_locations'))]" />
|
||||
</record>
|
||||
|
||||
<!-- Modify name and groups_id on original stock.location menu -->
|
||||
<record id="stock.menu_action_location_form" model="ir.ui.menu">
|
||||
<field name="name">Locations Technical</field>
|
||||
<field name="parent_id" ref="stock.menu_warehouse_config"/>
|
||||
<field name="action" ref="stock.action_location_form"/>
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="groups_id" eval="[(4, ref('base.group_erp_manager'))]" />
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user