Compare commits
1 Commits
14.0-web_t
...
14.0-imp-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6416957ad1 |
@@ -11,6 +11,8 @@ from odoo.osv import expression
|
|||||||
class AccountMove(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = 'account.move'
|
_inherit = 'account.move'
|
||||||
|
|
||||||
|
default_move_line_name = fields.Char(
|
||||||
|
string='Default Label', states={'posted': [('readonly', True)]})
|
||||||
# By default, we can still modify "ref" when account move is posted
|
# By default, we can still modify "ref" when account move is posted
|
||||||
# which seems a bit lazy for me...
|
# which seems a bit lazy for me...
|
||||||
ref = fields.Char(states={'posted': [('readonly', True)]})
|
ref = fields.Char(states={'posted': [('readonly', True)]})
|
||||||
@@ -178,35 +180,6 @@ class AccountMove(models.Model):
|
|||||||
])
|
])
|
||||||
move.suitable_journal_ids = self.env['account.journal'].search(domain)
|
move.suitable_journal_ids = self.env['account.journal'].search(domain)
|
||||||
|
|
||||||
def button_draft(self):
|
|
||||||
super().button_draft()
|
|
||||||
# Delete attached pdf invoice
|
|
||||||
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:
|
|
||||||
# with invoice.env.do_in_draft():
|
|
||||||
# invoice.number, invoice.state = invoice.move_name, 'open'
|
|
||||||
# attachment = self.env.ref('account.account_invoices').retrieve_attachment(invoice)
|
|
||||||
# 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', '=', self._get_invoice_attachment_name()),
|
|
||||||
('res_id', '=', move.id),
|
|
||||||
('res_model', '=', self._name),
|
|
||||||
('type', '=', 'binary'),
|
|
||||||
], limit=1)
|
|
||||||
if attachment:
|
|
||||||
attachment.unlink()
|
|
||||||
|
|
||||||
def _get_invoice_attachment_name(self):
|
|
||||||
self.ensure_one()
|
|
||||||
return '%s.pdf' % (self.name and self.name.replace('/', '_') or 'INV')
|
|
||||||
|
|
||||||
|
|
||||||
class AccountMoveLine(models.Model):
|
class AccountMoveLine(models.Model):
|
||||||
_inherit = 'account.move.line'
|
_inherit = 'account.move.line'
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
# Copyright 2021 Akretion
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
{
|
|
||||||
'name': 'Web Tab Title',
|
|
||||||
'description': """
|
|
||||||
Automatically set tab document.title when empty.
|
|
||||||
Important limitation: the tab will get its title only once you browse it.
|
|
||||||
""",
|
|
||||||
'version': '14.0.1.0.0',
|
|
||||||
'license': 'AGPL-3',
|
|
||||||
'author': 'Akretion',
|
|
||||||
'website': 'akretion.com',
|
|
||||||
'depends': [
|
|
||||||
'web',
|
|
||||||
],
|
|
||||||
'data': [
|
|
||||||
],
|
|
||||||
'demo': [
|
|
||||||
],
|
|
||||||
"data": ["views/web_tab_title.xml"],
|
|
||||||
"maintainers": ["rvalyi"],
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/* global vis, py */
|
|
||||||
odoo.define("web_tab_title.AbstractWebClient", function (require) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var AbstractWebClient = require('web.AbstractWebClient');
|
|
||||||
|
|
||||||
var TabTitleAbstractWebClient = AbstractWebClient.include({
|
|
||||||
|
|
||||||
_title_changed: function () {
|
|
||||||
// like the original except we change the title
|
|
||||||
// only when it's different from "Odoo" to avoid
|
|
||||||
// resetting the tab title when switching tabs.
|
|
||||||
var parts = _.sortBy(_.keys(this.get("title_part")), function (x) { return x; });
|
|
||||||
var tmp = "";
|
|
||||||
_.each(parts, function (part) {
|
|
||||||
var str = this.get("title_part")[part];
|
|
||||||
if (str) {
|
|
||||||
tmp = tmp ? tmp + " - " + str : str;
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
if (tmp != "Odoo") {
|
|
||||||
document.title = tmp;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return TabTitleAbstractWebClient;
|
|
||||||
});
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/* global vis, py */
|
|
||||||
odoo.define("web_tab_title.FormController", function (require) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var FormController = require('web.FormController');
|
|
||||||
|
|
||||||
var TabTitleController = FormController.include({
|
|
||||||
|
|
||||||
on_attach_callback: function () {
|
|
||||||
this._super.apply(this, arguments);
|
|
||||||
|
|
||||||
if (document.title == "Odoo") {
|
|
||||||
var form_name_elem = $("div.oe_title>h1");
|
|
||||||
if (form_name_elem.length == 0) {
|
|
||||||
form_name_elem = $('span.o_field_char[name="name"]')
|
|
||||||
}
|
|
||||||
var title = form_name_elem.text();
|
|
||||||
if (title !== '') {
|
|
||||||
// alternatively we could access the record
|
|
||||||
// in views/basic/basic_model.js
|
|
||||||
// but we would also we miss the model name
|
|
||||||
document.title = title + " - Odoo";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return TabTitleController;
|
|
||||||
});
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<odoo>
|
|
||||||
<template
|
|
||||||
id="assets_backend"
|
|
||||||
name="web_timeline assets"
|
|
||||||
inherit_id="web.assets_backend"
|
|
||||||
>
|
|
||||||
<xpath expr="." position="inside">
|
|
||||||
<script
|
|
||||||
type="text/javascript"
|
|
||||||
src="/web_tab_title/static/src/js/form_controller.js"
|
|
||||||
/>
|
|
||||||
<script
|
|
||||||
type="text/javascript"
|
|
||||||
src="/web_tab_title/static/src/js/abstract_web_client.js"
|
|
||||||
/>
|
|
||||||
</xpath>
|
|
||||||
</template>
|
|
||||||
</odoo>
|
|
||||||
Reference in New Issue
Block a user