Compare commits

..

12 Commits

Author SHA1 Message Date
clementmbr
2bfde2e346 [IMP] add a button on kanban to open child partner 2021-06-01 14:50:19 +02:00
Alexis de Lattre
de2e5f2121 stock_account_usability: show to_refund on stock.move form 2021-05-21 11:29:18 +02:00
Alexis de Lattre
42e014bcb1 sale_usability: add no-attachment filter on sale.order
account_usability: small code improvement on has_attachment
2021-05-20 19:29:31 +02:00
Alexis de Lattre
e70e3b23cf Improve picking view 2021-04-28 11:51:30 +02:00
Alexis de Lattre
50b4944c8b Always show location_id on stock inventory line 2021-04-28 11:34:28 +02:00
Alexis de Lattre
96bfda6e1b Add product_barcode in SO lines, PO lines, stock move lines and invoice lines with optional="hide"
Show warning about double VAT partner even when not in editable mode
2021-04-28 11:27:04 +02:00
Alexis de Lattre
cfb58ed80f Add inherit of account.move.line filter view 2021-04-27 16:25:50 +02:00
Alexis de Lattre
91e9c1fe33 account_usability: allow to manually create a journal item in cash and check journals 2021-04-22 23:58:03 +02:00
Alexis de Lattre
dff4e47cf5 Add sudo() to access ir.actions.act_windows... stupid v14! 2021-04-14 08:13:53 +02:00
Alexis de Lattre
452cc399c5 stock_usability: add button to access stock moves before button to access product moves, because stock moves are more important than product moves 2021-04-12 21:29:23 +02:00
Clément Mombereau
f4c22501a7 Merge pull request #144 from akretion/14.0-fix-message-post-picking
[FIX] picking.message_post() needs explicit 'body' argument
2021-04-07 00:53:22 +02:00
clementmbr
9e8874eb4b [FIX] picking.message_post() needs explicit 'body' argument 2021-04-07 00:04:02 +02:00
25 changed files with 245 additions and 166 deletions

View File

@@ -5,6 +5,7 @@
from odoo import api, fields, models
from odoo.tools import float_is_zero
from odoo.tools.misc import format_date
from odoo.osv import expression
class AccountMove(models.Model):
@@ -49,11 +50,11 @@ class AccountMove(models.Model):
def _compute_has_attachment(self):
iao = self.env['ir.attachment']
for move in self:
if iao.search([
if iao.search_count([
('res_model', '=', 'account.move'),
('res_id', '=', move.id),
('type', '=', 'binary'),
('company_id', '=', move.company_id.id)], limit=1):
('company_id', '=', move.company_id.id)]):
move.has_attachment = True
else:
move.has_attachment = False
@@ -157,6 +158,24 @@ class AccountMove(models.Model):
for x in sales]
inv.sale_dates = ", ".join(dates)
# allow to manually create moves not only in general journals,
# but also in cash journal and check journals (= bank journals not linked to a bank account)
@api.depends('company_id', 'invoice_filter_type_domain')
def _compute_suitable_journal_ids(self):
for move in self:
if move.invoice_filter_type_domain:
super(AccountMove, move)._compute_suitable_journal_ids()
else:
company_id = move.company_id.id or self.env.company.id
domain = expression.AND([
[('company_id', '=', company_id)],
expression.OR([
[('type', 'in', ('general', 'cash'))],
[('type', '=', 'bank'), ('bank_account_id', '=', False)]
])
])
move.suitable_journal_ids = self.env['account.journal'].search(domain)
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
@@ -176,6 +195,8 @@ class AccountMoveLine(models.Model):
matched_credit_ids = fields.One2many(string='Partial Reconcile Credit')
reconcile_string = fields.Char(
compute='_compute_reconcile_string', string='Reconcile', store=True)
# for optional display in tree view
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
def show_account_move_form(self):
self.ensure_one()

View File

@@ -30,6 +30,9 @@
<field name="matching_number" optional="hide"/>
<field name="reconcile_string" optional="show"/>
</xpath>
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='product_id']" position="after">
<field name="product_barcode" optional="hide"/>
</xpath>
</field>
</record>
@@ -58,6 +61,36 @@
</field>
</record>
<record id="view_account_move_line_filter" model="ir.ui.view">
<field name="name">account_usability.account_move_line_search</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_account_move_line_filter"/>
<field name="arch" type="xml">
<filter name="unposted" position="before">
<filter name="current_year" string="Current Year" domain="[('date', '&gt;=', (context_today().strftime('%Y-01-01'))), ('date', '&lt;=', (context_today().strftime('%Y-12-31')))]"/>
<filter name="previous_year" string="Previous Year" domain="[('date', '&gt;=', (context_today() + relativedelta(day=1, month=1, years=-1)).strftime('%Y-%m-%d')), ('date', '&lt;=', (context_today() + relativedelta(day=31, month=12, years=-1)).strftime('%Y-%m-%d'))]"/>
<separator/>
</filter>
<field name="partner_id" position="after">
<field name="reconcile_string" />
<field name="debit" filter_domain="['|', ('debit', '=', self), ('credit', '=', self)]" string="Debit or Credit"/>
</field>
<filter name="unreconciled" position="before">
<filter name="reconciled" string="Fully Reconciled" domain="[('full_reconcile_id', '!=', False)]"/>
</filter>
<filter name="unreconciled" position="attributes">
<attribute name="string">Unreconciled or Partially Reconciled</attribute>
</filter>
<!--
<field name="name" position="attributes">
<attribute name="string">Name or Reference</attribute>
</field> -->
<field name="partner_id" position="attributes">
<attribute name="domain">['|', ('parent_id', '=', False), ('is_company', '=', True)]</attribute>
</field>
</field>
</record>
<record id="account.action_move_journal_line" model="ir.actions.act_window">
<field name="context">{'default_move_type': 'entry', 'view_no_maturity': True}</field>
<!-- Remove 'search_default_misc_filter': 1 -->

View File

@@ -10,7 +10,7 @@
'summary': 'Better usability in base module',
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['base'],
'depends': ['base', 'contacts'],
'data': [
'security/group.xml',
'security/ir.model.access.csv',

View File

@@ -16,6 +16,19 @@
<xpath expr="//field[@name='child_ids']/form//field[@name='title']" position="attributes">
<attribute name="attrs"></attribute>
</xpath>
<!-- Show double VAT partner even when not in editable mode -->
<div attrs="{'invisible': [('same_vat_partner_id', '=', False)]}" position="attributes">
<attribute name="class">alert alert-warning</attribute>
</div>
<!-- Add a kanban button to open child partner -->
<xpath expr="//field[@name='child_ids']//kanban/templates/t/div" position="inside">
<div class="o_dropdown_kanban">
<a class="btn" role="button" title="Open"
t-att-href="'/web#id=' + record.id.raw_value + '&amp;action=%(contacts.action_contacts)d' + '&amp;menu_id=%(contacts.menu_contacts)d' + '&amp;view_type=form&amp;cids=1&amp;model=res.partner'">
<span class="fa fa-external-link" />
</a>
</div>
</xpath>
</field>
</record>

View File

@@ -71,3 +71,10 @@ class PurchaseOrder(models.Model):
# {'subtotal': 8932.23},
# ]
return res
class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
# for optional display in tree view
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")

View File

@@ -34,6 +34,9 @@
<xpath expr="//field[@name='order_line']/form//field[@name='analytic_tag_ids']" position="attributes">
<attribute name="groups">analytic.group_analytic_tags</attribute>
</xpath>
<xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="after">
<field name="product_barcode" optional="hide"/>
</xpath>
</field>
</record>

View File

@@ -1,91 +0,0 @@
.. 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
============================
Sale Shipping Address Domain
============================
Adds a sensible domain to the shipping address on sale form view
Installation
============
To install this module, you need to:
#. Do this ...
Configuration
=============
To configure this module, you need to:
#. Go to ...
.. figure:: path/to/local/image.png
:alt: alternative description
:width: 600 px
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: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example
Known issues / Roadmap
======================
* ...
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/{project_repo}/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.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Firstname Lastname <email.address@example.org>
* Second Person <second.person@example.org>
Funders
-------
The development of this module has been financially supported by:
* Company 1 name
* Company 2 name
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

View File

@@ -1 +0,0 @@
from . import models

View File

@@ -1,13 +0,0 @@
# Copyright 2021 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Sale Shipping and Invoice Domain",
"summary": """
Adds a sensible domain to the shipping and invoicing addresses on sale form view""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Akretion,Odoo Community Association (OCA)",
"depends": ["sale_stock", "sale_commercial_partner"],
"demo": [],
}

View File

@@ -1 +0,0 @@
from . import sale_order

View File

@@ -1,19 +0,0 @@
# Copyright 2021 Akretion France (http://www.akretion.com/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class SaleOrder(models.Model):
_inherit = "sale.order"
partner_invoice_id = fields.Many2one(
domain="['&', '|', "
"('company_id', '=', False), ('company_id', '=', company_id),"
"('id', 'child_of', commercial_partner_id)]"
)
partner_shipping_id = fields.Many2one(
domain="['&', '|', "
"('company_id', '=', False), ('company_id', '=', company_id),"
"('id', 'child_of', commercial_partner_id)]"
)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -21,6 +21,9 @@ class SaleOrder(models.Model):
fiscal_position_id = fields.Many2one(tracking=True)
# for reports
has_discount = fields.Boolean(compute='_compute_has_discount')
has_attachment = fields.Boolean(
compute='_compute_has_attachment',
search='_search_has_attachment')
@api.depends('order_line.discount')
def _compute_has_discount(self):
@@ -34,6 +37,30 @@ class SaleOrder(models.Model):
break
order.has_discount = has_discount
def _compute_has_attachment(self):
iao = self.env['ir.attachment']
for order in self:
if iao.search_count([
('res_model', '=', 'sale.order'),
('res_id', '=', order.id),
('type', '=', 'binary'),
('company_id', '=', order.company_id.id)]):
order.has_attachment = True
else:
order.has_attachment = False
def _search_has_attachment(self, operator, value):
att_order_ids = {}
if operator == '=':
search_res = self.env['ir.attachment'].search_read([
('res_model', '=', 'sale.order'),
('type', '=', 'binary'),
('res_id', '!=', False)], ['res_id'])
for att in search_res:
att_order_ids[att['res_id']] = True
res = [('id', value and 'in' or 'not in', list(att_order_ids))]
return res
# for report
def py3o_lines_layout(self):
self.ensure_one()
@@ -66,6 +93,10 @@ class SaleOrder(models.Model):
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
# for optional display in tree view
product_barcode = fields.Char(
related='product_id.barcode', string="Product Barcode")
@api.onchange('product_uom', 'product_uom_qty')
def product_uom_change(self):
# When the user has manually set a custom price

View File

@@ -26,6 +26,9 @@
<field name="date_order" position="after">
<field name="client_order_ref"/>
</field>
<xpath expr="//field[@name='order_line']/tree/field[@name='product_template_id']" position="after">
<field name="product_barcode" optional="hide"/>
</xpath>
</field>
</record>
@@ -62,6 +65,10 @@
<filter name="order_month" position="after">
<filter string="State" name="state_groupby" context="{'group_by': 'state'}"/>
</filter>
<filter name="activities_upcoming_all" position="after">
<separator/>
<filter name="no_attachment" string="Missing Attachment" domain="[('has_attachment', '=', False)]"/>
</filter>
</field>
</record>

View File

@@ -1,4 +1,4 @@
# Copyright 2019-2020 Akretion France (http://www.akretion.com)
# Copyright 2019-2021 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).
@@ -15,14 +15,13 @@ Stock Account Usability
The usability enhancements include:
NONE
- show to_refund on stock.move form view
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['stock_account'],
'data': [
],
'installable': False,
'depends': ['stock_account', 'stock_usability'],
'data': ['views/stock_move.xml'],
'installable': True,
}

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2021 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>
<record id="view_move_form" model="ir.ui.view">
<field name="name">stock_account_usability.stock.move.form</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock_usability.view_move_form" />
<field name="arch" type="xml">
<field name="price_unit" position="after">
<field name="to_refund" readonly="1"/>
</field>
</field>
</record>
</odoo>

View File

@@ -1,2 +0,0 @@
from . import stock_return_picking
from . import stock_quantity_history

View File

@@ -5,5 +5,5 @@ from . import stock_warehouse_orderpoint
from . import stock_quant
from . import procurement_group
from . import procurement_scheduler_log
from . import product_template
from . import product
from . import res_partner

View File

@@ -0,0 +1,31 @@
# Copyright 2016-2021 Akretion France
# @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 ProductTemplate(models.Model):
_inherit = 'product.template'
tracking = fields.Selection(tracking=True)
sale_delay = fields.Float(tracking=True)
# the 'stock' module adds 'product' in type...
# but forgets to make it the default
type = fields.Selection(default='product')
def action_view_stock_move(self):
action = self.env.ref('stock.stock_move_action').sudo().read()[0]
action['domain'] = [('product_id.product_tmpl_id', 'in', self.ids)]
action['context'] = {'search_default_done': True}
return action
class ProductProduct(models.Model):
_inherit = 'product.product'
def action_view_stock_move(self):
action = self.env.ref('stock.stock_move_action').sudo().read()[0]
action['domain'] = [('product_id', 'in', self.ids)]
action['context'] = {'search_default_done': True}
return action

View File

@@ -1,15 +0,0 @@
# Copyright 2016-2020 Akretion France
# @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 ProductTemplate(models.Model):
_inherit = 'product.template'
tracking = fields.Selection(tracking=True)
sale_delay = fields.Float(tracking=True)
# the 'stock' module adds 'product' in type...
# but forgets to make it the default
type = fields.Selection(default='product')

View File

@@ -2,7 +2,7 @@
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, _
from odoo import fields, models, _
from odoo.exceptions import UserError
import logging
@@ -12,6 +12,9 @@ logger = logging.getLogger(__name__)
class StockMove(models.Model):
_inherit = 'stock.move'
# for optional display in tree view
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
# def name_get(self):
# '''name_get of stock_move is important for the reservation of the
# quants: so want to add the name of the customer and the expected date
@@ -37,7 +40,7 @@ class StockMove(models.Model):
picking = move.picking_id
if picking:
product = move.product_id
picking.message_post(_(
picking.message_post(body=_(
"Product <a href=# data-oe-model=product.product "
"data-oe-id=%d>%s</a> qty %s %s <b>unreserved</b>")
% (product.id, product.display_name,
@@ -49,6 +52,9 @@ class StockMove(models.Model):
class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
# for optional display in tree view
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
# TODO: I think it's not complete
def button_do_unreserve(self):
for moveline in self:
@@ -60,7 +66,7 @@ class StockMoveLine(models.Model):
picking = moveline.move_id.picking_id
if picking:
product = moveline.product_id
picking.message_post(_(
picking.message_post(body=_(
"Product <a href=# data-oe-model=product.product "
"data-oe-id=%d>%s</a> qty %s %s <b>unreserved</b>")
% (product.id, product.display_name,

View File

@@ -19,5 +19,38 @@
</field>
</record>
<record id="product_template_form_view_procurement_button" model="ir.ui.view">
<field name="name">stock_usability.product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.product_template_form_view_procurement_button"/>
<field name="arch" type="xml">
<button name="action_view_stock_move_lines" position="before">
<button string="Stock Moves"
type="object"
name= "action_view_stock_move"
attrs="{'invisible': [('type', 'not in', ('product', 'consu'))]}"
groups="stock.group_stock_user"
class="oe_stat_button" icon="fa-exchange"
/>
</button>
</field>
</record>
<record id="product_form_view_procurement_button" model="ir.ui.view">
<field name="name">stock_usability.product.product.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="stock.product_form_view_procurement_button"/>
<field name="arch" type="xml">
<button name="action_view_stock_move_lines" position="before">
<button string="Stock Moves"
type="object"
name= "action_view_stock_move"
attrs="{'invisible': [('type', 'not in', ('product', 'consu'))]}"
groups="stock.group_stock_user"
class="oe_stat_button" icon="fa-exchange"
/>
</button>
</field>
</record>
</odoo>

View File

@@ -21,6 +21,9 @@
<attribute name="decoration-info">product_qty &gt; theoretical_qty</attribute>
<attribute name="decoration-danger">product_qty &lt; theoretical_qty</attribute>
</tree>
<field name="location_id" position="attributes">
<attribute name="invisible">0</attribute>
</field>
</field>
</record>

View File

@@ -58,6 +58,9 @@
states="partially_available,assigned"
icon="fa-ban"/>
</field>
<field name="product_id" position="after">
<field name="product_barcode" optional="hide"/>
</field>
</field>
</record>
@@ -78,6 +81,20 @@
states="partially_available,assigned"
icon="fa-ban"/>
</field>
<field name="product_id" position="after">
<field name="product_barcode" optional="hide"/>
</field>
</field>
</record>
<!-- View embedded in picking -->
<record id="view_stock_move_line_detailed_operation_tree" model="ir.ui.view">
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_stock_move_line_detailed_operation_tree" />
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="product_barcode" optional="hide"/>
</field>
</field>
</record>

View File

@@ -30,9 +30,12 @@
</xpath>
<xpath expr="//field[@name='move_ids_without_package']/tree/field[@name='location_id']" position="replace"/>
<xpath expr="//field[@name='move_ids_without_package']/tree/field[@name='location_dest_id']" position="replace"/>
<xpath expr="//field[@name='move_ids_without_package']/tree/field[@name='name']" position="replace"/>
<xpath expr="//field[@name='move_ids_without_package']/tree/field[@name='product_id']" position="after">
<field name="location_id" groups="stock.group_stock_multi_locations"/>
<field name="location_dest_id" groups="stock.group_stock_multi_locations"/>
<field name="product_barcode" optional="hide"/>
<field name="name" optional="hide"/>
<field name="location_id" groups="stock.group_stock_multi_locations" optional="show"/>
<field name="location_dest_id" groups="stock.group_stock_multi_locations" optional="show"/>
</xpath>
<xpath expr="//field[@name='move_ids_without_package']/tree/button[@name='action_assign_serial']" position="after">
<button type="object" name="button_do_unreserve" string="Unreserve"
@@ -40,15 +43,6 @@
states="partially_available,assigned"
icon="fa-ban"/>
</xpath>
<!-- STOCK MOVE LINE -->
<!--
<xpath expr="//field[@name='move_line_ids_without_package']/tree/field[@name='location_id']" position="attributes">
<attribute name="attrs">{}</attribute>
</xpath>
<xpath expr="//field[@name='move_line_ids_without_package']/tree/field[@name='location_dest_id']" position="attributes">
<attribute name="attrs">{}</attribute>
</xpath>
-->
</field>
</record>