summaryrefslogtreecommitdiff
path: root/addons/account/static
diff options
context:
space:
mode:
authorwan <wan@odoo.com>2019-11-27 15:57:42 +0000
committerwan <wan@odoo.com>2020-02-05 13:59:43 +0000
commitdfd01b8c5c7e1177f37bf199790a0732a61eed78 (patch)
tree6ebb7f50ba554fb4138954c958f799836aae91a7 /addons/account/static
parenta6d7c7b04a48669037e6568849a26571602386f6 (diff)
[IMP] account: rework name sequences
Task 2146469 Rework the name computation: * It doesn't use ir.sequence anymore * It is an editable computed field * Add a renaming tool This allows the user to tweak the sequences more easily than having to get through the ir.sequence settings. The sequence depends on a parameter of the journal: continuous, montly and yearly restart of the sequence. Everytime a new period is started, try to make a pattern form another period. The incrementing is done by taking the previous name, ordered lexicographically, splitting it by taking the digits at the end, adding 1 and re contstruct with the prefix. ** This means there could be cases where the prefix has a big importance on the next number. For instance, if you have INVOICE/2019/0001 INVOICE/2019/0002 and then rename the last one to INV/2019/0002, don't expect the next number to be INV/2019/0003. It will be INVOICE/2019/0002 (again) because the highest number was INVOICE/2019/0001. You will then end up with INVOICE/2019/0001 INV/2019/0002 INVOICE/2019/0002 closes odoo/odoo#41485 Related: odoo/enterprise#7189 Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Diffstat (limited to 'addons/account/static')
-rw-r--r--addons/account/static/src/js/account_resequence_field.js32
-rw-r--r--addons/account/static/src/scss/variables.scss14
-rw-r--r--addons/account/static/src/xml/account_resequence.xml25
3 files changed, 71 insertions, 0 deletions
diff --git a/addons/account/static/src/js/account_resequence_field.js b/addons/account/static/src/js/account_resequence_field.js
new file mode 100644
index 00000000000..0f918e9a297
--- /dev/null
+++ b/addons/account/static/src/js/account_resequence_field.js
@@ -0,0 +1,32 @@
+odoo.define('account.ShowResequenceRenderer', function (require) {
+"use strict";
+
+const { Component } = owl;
+const { useState } = owl.hooks;
+const AbstractFieldOwl = require('web.AbstractFieldOwl');
+const field_registry = require('web.field_registry');
+
+class ChangeLine extends Component { }
+ChangeLine.template = 'account.ResequenceChangeLine';
+ChangeLine.props = ["changeLine", 'ordering'];
+
+
+class ShowResequenceRenderer extends AbstractFieldOwl {
+ constructor(...args) {
+ super(...args);
+ this.data = this.value ? JSON.parse(this.value) : {
+ changeLines: [],
+ ordering: 'date',
+ };
+ }
+ async willUpdateProps(nextProps) {
+ await super.willUpdateProps(nextProps);
+ Object.assign(this.data, JSON.parse(this.value));
+ }
+}
+ShowResequenceRenderer.template = 'account.ResequenceRenderer';
+ShowResequenceRenderer.components = { ChangeLine }
+
+field_registry.add('account_resequence_widget', ShowResequenceRenderer);
+return ShowResequenceRenderer;
+});
diff --git a/addons/account/static/src/scss/variables.scss b/addons/account/static/src/scss/variables.scss
index 72a0a315181..3e79231cecf 100644
--- a/addons/account/static/src/scss/variables.scss
+++ b/addons/account/static/src/scss/variables.scss
@@ -3,3 +3,17 @@ $o-account-main-table-borders-padding: 3px;
$o-account-light-border: 1px solid #bbb;
$o-account-initial-line-background: #f0f0f0;
$o-account-info-color: #44c;
+
+
+@keyframes animate-red {
+ 0% {
+ color: red;
+ }
+ 100% {
+ color: inherit;
+ }
+}
+
+.animate {
+ animation: animate-red 1s ease;
+}
diff --git a/addons/account/static/src/xml/account_resequence.xml b/addons/account/static/src/xml/account_resequence.xml
new file mode 100644
index 00000000000..59ea77e5fbd
--- /dev/null
+++ b/addons/account/static/src/xml/account_resequence.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<templates>
+
+ <div t-name="account.ResequenceRenderer" owl="1" class="d-block">
+ <table t-if="data.changeLines.length" class="table table-sm">
+ <thead><tr>
+ <th>Date</th>
+ <th>Before</th>
+ <th>After</th>
+ </tr></thead>
+ <tbody t-foreach="data.changeLines" t-as="changeLine" t-key="changeLine.current_name">
+ <ChangeLine changeLine="changeLine" ordering="data.ordering"/>
+ </tbody>
+ </table>
+ </div>
+
+ <t t-name="account.ResequenceChangeLine" owl="1">
+ <tr>
+ <td t-esc="props.changeLine.date"/>
+ <td t-esc="props.changeLine.current_name"/>
+ <td t-if="props.ordering == 'keep'" t-esc="props.changeLine.new_by_name" t-attf-class="{{ props.changeLine.new_by_name != props.changeLine.new_by_date ? 'animate' : ''}}"/>
+ <td t-else="" t-esc="props.changeLine.new_by_date" t-attf-class="{{ props.changeLine.new_by_name != props.changeLine.new_by_date ? 'animate' : ''}}"/>
+ </tr>
+ </t>
+</templates>