Compare commits

..

17 Commits

Author SHA1 Message Date
Alexis de Lattre
d3d4e7346e [MIG] sale_order_add_bom from v10 to v14 2022-03-29 11:36:59 +02:00
Alexis de Lattre
5acaa73fae sale_order_add_bom: add kit wizard now available on pickings 2022-03-29 10:32:10 +02:00
Alexis de Lattre
fc57c6259e Remove _rec_name from mrp.bom because there is now a native name_get() 2022-03-29 10:32:10 +02:00
Alexis de Lattre
da6185238d sale_order_add_bom: fix related field definition 2022-03-29 10:32:10 +02:00
Alexis de Lattre
45234bbb47 FIX my previous commit: related_sudo -> compute_sudo 2022-03-29 10:32:10 +02:00
Alexis de Lattre
2b3974d90d Add related_sudo where it may be needed
PEP8 fix
2022-03-29 10:32:10 +02:00
Alexis de Lattre
a04ab4592e Add module sale_force_invoice_status 2022-03-29 10:32:10 +02:00
Stéphane Bidoul (ACSONE)
385db5c722 [10.0] setup.py and addons versions (#35)
* [IMP] set 10.0 version prefix in all installable addons

* [FIX] 10.0 instead of 9.0 version prefix for sale_order_add_bom on 10.0 branch

* [ADD] setup.py for all installable addons
2022-03-29 10:32:10 +02:00
Alexis de Lattre
feb39edd22 Port sale_order_add_bom to v10 2022-03-29 10:32:10 +02:00
Alexis de Lattre
d331dee3ba Add modules sale_from_private_stock and sale_order_add_bom
Port base_company_extension to v10
Avoid blockage on l10n_fr_infogreffe_connector
2022-03-29 10:32:10 +02:00
Alexis de Lattre
6907302f8e [MIG] sale_purchase_no_product_template_menu 2022-03-28 17:31:32 +02:00
Alexis de Lattre
a3e23ab5e7 [MIG] base_mail_sender_bcc from v10 to v14
Code almost unchanged.
2022-03-28 17:22:13 +02:00
Alexis de Lattre
a850586716 account_usability: account.invoice.report in pivot by default (instead of graph) 2022-03-15 15:46:50 +01:00
Alexis de Lattre
fdef51ea57 account_usability: add name_search() on account.incoterms 2022-03-11 09:01:32 +01:00
Clément Mombereau
806389e04b Merge pull request #163 from akretion/14.0-explicit-reconcile-error
account_usability: explicit error msg on unposted reconciliation
2022-03-08 19:23:12 -03:00
clementmbr
c12b496004 account_usability: explicit error msg on unposted reconciliation 2022-03-08 19:21:02 -03:00
Alexis de Lattre
447b0107be account_usability: change the behavior of 'date' on in_invoice/in_refund when the 'invoice_date' is changed 2022-03-08 21:02:55 +01:00
26 changed files with 461 additions and 68 deletions

View File

@@ -14,3 +14,13 @@ class AccountIncoterms(models.Model):
for rec in self:
res.append((rec.id, '[%s] %s' % (rec.code, rec.name)))
return res
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
if args is None:
args = []
if name and operator == 'ilike':
recs = self.search([('code', '=ilike', name + '%')] + args, limit=limit)
if recs:
return recs.name_get()
return super().name_search(name=name, args=args, operator=operator, limit=limit)

View File

@@ -2,10 +2,12 @@
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
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
from datetime import timedelta
from odoo.exceptions import UserError
class AccountMove(models.Model):
@@ -207,6 +209,18 @@ class AccountMove(models.Model):
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
# we have a company tax_lock_date and the invoice has taxes
# and invoice_date <= tax_lock_date
date = super()._get_accounting_date(invoice_date, has_tax)
if self.is_purchase_document(include_receipts=True):
tax_lock_date = self.company_id.tax_lock_date
if invoice_date and tax_lock_date and has_tax and invoice_date <= tax_lock_date:
invoice_date = tax_lock_date + timedelta(days=1)
date = invoice_date
return date
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
@@ -263,3 +277,14 @@ class AccountMoveLine(models.Model):
if no_product_code_param and no_product_code_param == 'True':
self = self.with_context(display_default_code=False)
return super()._get_computed_name()
def reconcile(self):
"""Explicit error message if unposted lines"""
unposted_ids = self.filtered(lambda l: l.move_id.state != "posted")
if unposted_ids:
m = _("Please post the following entries before reconciliation :")
sep = "\n - "
unpost = sep.join([am.display_name for am in unposted_ids.move_id])
raise UserError(m + sep + unpost)
return super().reconcile()

View File

@@ -40,10 +40,12 @@
<record id="account.action_account_invoice_report_all_supp" model="ir.actions.act_window">
<field name="context">{'search_default_current': 1, 'search_default_supplier': 1, 'group_by': ['invoice_date']}</field> <!-- Remove group_by_no_leaf, which breaks tree view -->
<field name="view_mode">pivot,graph</field>
</record>
<record id="account.action_account_invoice_report_all" model="ir.actions.act_window">
<field name="context">{'search_default_current': 1, 'search_default_customer': 1, 'group_by': ['invoice_date']}</field> <!-- Remove group_by_no_leaf, which breaks tree view -->
<field name="view_mode">pivot,graph</field>
</record>
<record id="view_account_invoice_report_pivot" model="ir.ui.view">

View File

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

View File

@@ -0,0 +1,21 @@
# Copyright 2017-2022 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).
{
'name': 'Mail Sender Bcc',
'version': '14.0.1.0.0',
'category': 'Mail',
'license': 'AGPL-3',
'summary': "Always send a copy of the mail to the sender",
'description': """
Mail Sender Bcc
===============
With this module, when Odoo sends an outgoing email, it adds the sender as Bcc (blind copy) of the email.
""",
'author': 'Akretion',
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['base'],
'installable': True,
}

View File

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

View File

@@ -0,0 +1,27 @@
# Copyright 2017-2022 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 models
class IrMailServer(models.Model):
_inherit = 'ir.mail_server'
def build_email(
self, email_from, email_to, subject, body, email_cc=None,
email_bcc=None, reply_to=False, attachments=None,
message_id=None, references=None, object_id=False,
subtype='plain', headers=None,
body_alternative=None, subtype_alternative='plain'):
if email_from:
if email_bcc is None:
email_bcc = [email_from]
elif isinstance(email_bcc, list) and email_from not in email_bcc:
email_bcc.append(email_from)
return super().build_email(
email_from, email_to, subject, body, email_cc=email_cc,
email_bcc=email_bcc, reply_to=reply_to, attachments=attachments,
message_id=message_id, references=references, object_id=object_id,
subtype=subtype, headers=headers,
body_alternative=body_alternative, subtype_alternative=subtype_alternative)

View File

@@ -33,7 +33,6 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
'views/product_template_view.xml',
'views/product_product.xml',
'views/product_category_view.xml',
'views/product_attribute_view.xml',
],
'installable': True,
}

View File

@@ -3,4 +3,3 @@ from . import product_template
from . import product_supplierinfo
from . import product_pricelist
from . import product_category
from . import product_attribute

View File

@@ -1,27 +0,0 @@
# Copyright (C) 2022 Akretion (<http://www.akretion.com>).
# @author Kévin Roche <kevin.roche@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class ProductAttribute(models.Model):
_inherit = "product.attribute"
values_count = fields.Integer(compute="_compute_values_count")
@api.depends("value_ids")
def _compute_values_count(self):
for attr in self:
attr.values_count = len(attr.value_ids)
def show_values_ids(self):
return {
"name": "Attributes Lines",
"type": "ir.actions.act_window",
"res_id": self.id,
"view_mode": "tree",
"res_model": "product.attribute.value",
"view_id":self.env.ref("product_usability.product_attribute_value_view_tree").id,
"target": "current",
"domain": [("id", "in", self.value_ids.ids)],
}

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="product_attribute_values_button" model="ir.ui.view">
<field name="model">product.attribute</field>
<field name="inherit_id" ref="product.product_attribute_view_form" />
<field name="arch" type="xml">
<group name="main_fields" position='before'>
<div class="oe_button_box" name="button_box">
<button
name="show_values_ids"
type="object"
class="oe_stat_button"
icon="fa-tasks"
>
<field
name="values_count"
widget="statinfo"
string="Attribute Values"
/>
</button>
</div>
</group>
</field>
</record>
<record model="ir.ui.view" id="product_attribute_value_view_tree">
<field name="name">product.attribute.value.view.tree</field>
<field name="model">product.attribute.value</field>
<field name="arch" type="xml">
<tree string="Attributes Values">
<field name="name"/>
<field name="is_custom"/>
</tree>
</field>
</record>
</odoo>

View File

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

View File

@@ -0,0 +1,29 @@
# Copyright 2016-2022 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).
{
'name': 'Sale Order Add Bom',
'version': '14.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Wizard to select a bom from a sale order',
'description': """
This module adds a wizard *Add Kit* on the form view of a quotation that allows the user to select a 'kit' BOM: Odoo will automatically add the components of the kit as sale order lines.
The wizard *Add Kit* is also available on a draft picking.
This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'https://github.com/akretion/odoo-usability',
'depends': ['sale', 'mrp'],
'data': [
'wizard/sale_add_phantom_bom_view.xml',
'views/sale_order.xml',
'views/stock_picking.xml',
'security/ir.model.access.csv',
],
'installable': True,
}

View File

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

View File

@@ -0,0 +1,11 @@
# Copyright 2016-2022 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 models, fields
class MrpBom(models.Model):
_inherit = 'mrp.bom'
sale_ok = fields.Boolean(related='product_tmpl_id.sale_ok', store=True)

View File

@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sale_add_phantom_bom_sale,Full access on sale.add.phantom.bom wizard to sale user,model_sale_add_phantom_bom,sales_team.group_sale_salesman,1,1,1,1
access_sale_add_phantom_bom_stock,Full access on sale.add.phantom.bom wizard to stock user,model_sale_add_phantom_bom,stock.group_stock_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sale_add_phantom_bom_sale Full access on sale.add.phantom.bom wizard to sale user model_sale_add_phantom_bom sales_team.group_sale_salesman 1 1 1 1
3 access_sale_add_phantom_bom_stock Full access on sale.add.phantom.bom wizard to stock user model_sale_add_phantom_bom stock.group_stock_user 1 1 1 1

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016-2022 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_order_form" model="ir.ui.view">
<field name="name">add.bom.sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<button name="action_quotation_send" position="before">
<button name="%(sale_add_phantom_bom_action)d" type="action"
string="Add Kit" states="draft,sent"/>
</button>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2021-2022 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>
<data>
<record id="view_picking_form" model="ir.ui.view">
<field name="name">add.bom.stock.picking.form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<button name="action_confirm" position="after">
<button name="%(sale_add_phantom_bom_action)d" type="action"
string="Add Kit" states="draft" groups="stock.group_stock_user"/>
</button>
</field>
</record>
</data>
</odoo>

View File

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

View File

@@ -0,0 +1,96 @@
# Copyright 2016-2022 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 models, fields, api, _
from odoo.exceptions import UserError
from odoo.tools import float_is_zero
class SaleAddPhantomBom(models.TransientModel):
_name = 'sale.add.phantom.bom'
_description = 'Add Kit to Quotation'
@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
if self._context.get('active_model') == 'sale.order':
res['sale_id'] = self._context['active_id']
sale = self.env['sale.order'].browse(res['sale_id'])
res['company_id'] = sale.company_id.id
elif self._context.get('active_model') == 'stock.picking':
res['picking_id'] = self._context['active_id']
picking = self.env['stock.picking'].browse(res['picking_id'])
res['company_id'] = picking.company_id.id
else:
raise UserError(_(
"The wizard can only be started from a sale order or a picking."))
return res
bom_id = fields.Many2one(
'mrp.bom', 'Kit', required=True,
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id), ('type', '=', 'phantom'), ('sale_ok', '=', True)]")
company_id = fields.Many2one('res.company', string='Company', required=True)
qty = fields.Integer(
string='Number of Kits to Add', default=1, required=True)
sale_id = fields.Many2one(
'sale.order', string='Quotation')
picking_id = fields.Many2one(
'stock.picking', string='Picking')
@api.model
def _prepare_sale_order_line(self, bom_line, sale_order, wizard_qty):
qty_in_product_uom = bom_line.product_uom_id._compute_quantity(
bom_line.product_qty,
bom_line.product_id.uom_id)
vals = {
'product_id': bom_line.product_id.id,
'product_uom_qty': qty_in_product_uom * wizard_qty,
'order_id': sale_order.id,
}
# on sale.order.line, company_id is a related field
return vals
@api.model
def _prepare_stock_move(self, bom_line, picking, wizard_qty):
product = bom_line.product_id
qty_in_product_uom = bom_line.product_uom_id._compute_quantity(
bom_line.product_qty, product.uom_id)
vals = {
'product_id': product.id,
'product_uom_qty': qty_in_product_uom * wizard_qty,
'product_uom': product.uom_id.id,
'picking_id': picking.id,
'company_id': picking.company_id.id,
'location_id': picking.location_id.id,
'location_dest_id': picking.location_dest_id.id,
'name': product.partner_ref,
}
return vals
def add(self):
self.ensure_one()
assert self.sale_id or self.picking_id, 'No related sale_id or picking_id'
if self.qty < 1:
raise UserError(_(
"The number of kits to add must be 1 or superior"))
assert self.bom_id.type == 'phantom', 'The BOM is not a kit'
if not self.bom_id.bom_line_ids:
raise UserError(_("The selected kit is empty !"))
prec = self.env['decimal.precision'].precision_get(
'Product Unit of Measure')
solo = self.env['sale.order.line']
smo = self.env['stock.move']
for line in self.bom_id.bom_line_ids:
if float_is_zero(line.product_qty, precision_digits=prec):
continue
# The onchange is played in the inherit of the create()
# of sale order line in the 'sale' module
# TODO: if needed, we could increment existing order lines
# with the same product instead of always creating new lines
if self.sale_id:
vals = self._prepare_sale_order_line(line, self.sale_id, self.qty)
solo.create(vals)
elif self.picking_id:
vals = self._prepare_stock_move(line, self.picking_id, self.qty)
smo.create(vals)

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016-2022 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="sale_add_phantom_bom_form" model="ir.ui.view">
<field name="name">sale.add.phantom.bom.form</field>
<field name="model">sale.add.phantom.bom</field>
<field name="arch" type="xml">
<form>
<group name="main">
<field name="sale_id" invisible="1"/>
<field name="picking_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="bom_id" default_focus="1"/>
<field name="qty"/>
</group>
<footer>
<button name="add" type="object"
class="btn-primary" string="Add"/>
<button special="cancel" string="Cancel"/>
</footer>
</form>
</field>
</record>
<record id="sale_add_phantom_bom_action" model="ir.actions.act_window">
<field name="name">Add Kit</field>
<field name="res_model">sale.add.phantom.bom</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View File

@@ -0,0 +1,29 @@
# Copyright 2015-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).
{
"name": "Sale Purchase No Product Template Menu",
"version": "14.0.1.0.0",
"category": "Sale and Purchase",
"license": "AGPL-3",
"summary": "Replace product.template menu entries by product.product menu entries",
"description": """
Sale Purchase No Product Template
=================================
This module replaces the menu entries for product.template by menu entries for product.product in the *Sales* and *Purchases* menu entries. With this module, the only menu entry for product.template is in the menu *Sales > Configuration > Product Categories and Attributes*.
This module also switches to the tree view by default for Product menu entries, instead of the kanban view.
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
""",
"author": "Akretion",
"website": "http://www.akretion.com",
"depends": [
"purchase",
"sale",
],
"data": ["view.xml"],
"installable": True,
}

View File

@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_purchase_no_product_template_menu
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2022-03-28 17:19+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 3.0\n"
#. module: sale_purchase_no_product_template_menu
#: model:ir.ui.menu,name:sale_purchase_no_product_template_menu.sale_config_product_template_menu
msgid "Product Templates"
msgstr "Modèles d'article"
#. module: sale_purchase_no_product_template_menu
#: model:ir.actions.act_window,name:sale_purchase_no_product_template_menu.product_product_action_purchased
#: model:ir.actions.act_window,name:sale_purchase_no_product_template_menu.product_product_action_sell
msgid "Products"
msgstr "Articles"

View File

@@ -0,0 +1,25 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_purchase_no_product_template_menu
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \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: sale_purchase_no_product_template_menu
#: model:ir.ui.menu,name:sale_purchase_no_product_template_menu.sale_config_product_template_menu
msgid "Product Templates"
msgstr ""
#. module: sale_purchase_no_product_template_menu
#: model:ir.actions.act_window,name:sale_purchase_no_product_template_menu.product_product_action_purchased
#: model:ir.actions.act_window,name:sale_purchase_no_product_template_menu.product_product_action_sell
msgid "Products"
msgstr ""

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2015-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).
-->
<odoo>
<!-- PURCHASE -->
<record id="product_product_action_purchased" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">product.product</field>
<field name="view_mode">tree,form,kanban</field>
<field name="context">{'search_default_filter_to_purchase': 1}</field>
<field name="search_view_id" eval="False"/> <!-- Force empty -->
<field name="view_id" eval="False"/> <!-- Force empty -->
</record>
<record id="purchase.menu_procurement_partner_contact_form" model="ir.ui.menu">
<field name="action" ref="product_product_action_purchased"/>
</record>
<!-- SALE -->
<!-- I'd prefer to inherit product.product_normal_action_sell and
change the "name" field, but it doesn't work with translation,
so I redefine a new menu entry -->
<record id="product_product_action_sell" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">product.product</field>
<field name="view_mode">tree,form,kanban</field>
<field name="context">{'search_default_filter_to_sell': 1}</field>
<field name="search_view_id" eval="False"/>
<field name="view_id" ref="product.product_product_tree_view"/>
<field name="search_view_id" ref="product.product_search_form_view"/>
</record>
<!-- To keep good translations, we re-use the product.template menu
entry and link it to product product -->
<record id="sale.menu_product_template_action" model="ir.ui.menu">
<!-- related action is "product.product_template_action" -->
<field name="action" ref="product_product_action_sell"/>
</record>
<record id="product.product_template_action" model="ir.actions.act_window">
<field name="name">Product Templates</field> <!-- native value is "Products" -->
<field name="view_mode">tree,form,kanban</field>
<field name="view_id" eval="False"/>
<field name="context">{}</field>
</record>
<!-- Create a product template menu entry in configuration -->
<menuitem id="sale_config_product_template_menu" action="product.product_template_action"
parent="sale.prod_config_main"/>
<record id="product.product_normal_action_sell" model="ir.actions.act_window">
<field name="view_mode">tree,form,kanban</field>
</record>
</odoo>