[IMP] stock_location_empty: black, isort, prettier

This commit is contained in:
sonhd
2021-12-19 13:38:53 +07:00
parent 5a012ba36d
commit 7a5c189798
5 changed files with 81 additions and 41 deletions

View File

@@ -0,0 +1 @@
../../../../stock_location_empty

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@@ -1,18 +1,19 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{'name': 'Stock Location Empty',
'version': '12.0.1.0.0',
'author': 'Camptocamp, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'category': 'stock',
'depends': [
'stock',
{
"name": "Stock Location Empty",
"version": "12.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "stock",
"depends": [
"stock",
],
"website": "https://github.com/OCA/stock-logistics-warehouse",
'data': [
'views/stock.xml',
"data": [
"views/stock.xml",
],
'installable': True,
'application': False,
"installable": True,
"application": False,
}

View File

@@ -6,15 +6,15 @@ from odoo import api, fields, models
class StockLocation(models.Model):
_inherit = 'stock.location'
_inherit = "stock.location"
stock_amount = fields.Integer(
compute='_compute_location_amount', search='_search_location_amount'
compute="_compute_location_amount", search="_search_location_amount"
)
@api.multi
def _search_location_amount(self, operator, value):
if operator not in ('=', '!=', '<', '<=', '>', '>='):
if operator not in ("=", "!=", "<", "<=", ">", ">="):
return []
# pylint: disable=sql-injection
self.env.cr.execute(
@@ -27,7 +27,7 @@ class StockLocation(models.Model):
(value,),
)
ids = [row[0] for row in self.env.cr.fetchall()]
return [('id', 'in', ids)]
return [("id", "in", ids)]
@api.multi
def _compute_location_amount(self):

View File

@@ -6,7 +6,11 @@
<field name="model">stock.location</field>
<field name="priority" eval="2" />
<field name="arch" type="xml">
<tree string="Stock Location" decoration-info="usage=='view'" decoration-danger="usage=='internal'">
<tree
string="Stock Location"
decoration-info="usage=='view'"
decoration-danger="usage=='internal'"
>
<field name="display_name" />
<field name="usage" />
<field name="company_id" groups="base.group_multi_company" />
@@ -22,7 +26,12 @@
<field name="arch" type="xml">
<field name="location_id" position="after">
<separator />
<filter name="stock_amount" string="Empty" domain="[('stock_amount', '=', 0)]" help="Empty stock"/>
<filter
name="stock_amount"
string="Empty"
domain="[('stock_amount', '=', 0)]"
help="Empty stock"
/>
</field>
</field>
</record>
@@ -34,11 +43,31 @@
<search string="Stock Locations">
<field name="name" string="Stock Locations" />
<field name="location_id" string="Parent Location" />
<filter name="in_location" string="Internal" domain="[('usage', '=', 'internal')]" help="Internal Locations"/>
<filter name="customer" string="Customer" domain="[('usage', '=', 'customer')]" help="Customer Locations"/>
<filter name="supplier" string="Vendor" domain="[('usage', '=', 'supplier')]" help="Vendor Locations"/>
<filter
name="in_location"
string="Internal"
domain="[('usage', '=', 'internal')]"
help="Internal Locations"
/>
<filter
name="customer"
string="Customer"
domain="[('usage', '=', 'customer')]"
help="Customer Locations"
/>
<filter
name="supplier"
string="Vendor"
domain="[('usage', '=', 'supplier')]"
help="Vendor Locations"
/>
<separator />
<filter name="stock_amount" string="Empty" domain="[('stock_amount', '=', 0)]" help="Empty stock"/>
<filter
name="stock_amount"
string="Empty"
domain="[('stock_amount', '=', 0)]"
help="Empty stock"
/>
</search>
</field>
</record>
@@ -50,13 +79,16 @@
<field name="view_type">form</field>
<field name="view_id" ref="view_location_tree3" />
<field name="search_view_id" ref="view_location_search_empty_2" />
<field name="context">{'search_default_in_location':1, 'search_default_stock_amount': 1}</field>
<field
name="context"
>{'search_default_in_location':1, 'search_default_stock_amount': 1}</field>
</record>
<menuitem
id="stock_location_empty_menu"
name="Empty stock"
parent="stock.menu_stock_inventory_control"
action="action_stock_location_empty"/>
action="action_stock_location_empty"
/>
</odoo>