summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2012-10-01 13:09:48 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2012-10-01 13:09:48 +0200
commitac84e4800a4ebcc012cd8012f2b52491a6032333 (patch)
treed265b876b56a67ecd57dbcf10c8c035d4a75493b
parentef1d6592e2a676f14eb8076fab10f7f06245c034 (diff)
now renders something
bzr revid: nicolas.vanhoren@openerp.com-20121001110948-qu7f3ancrfa73rxw
-rw-r--r--addons/hr_timesheet_sheet/static/src/js/timesheet.js36
-rw-r--r--addons/hr_timesheet_sheet/static/src/xml/timesheet.xml22
2 files changed, 51 insertions, 7 deletions
diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js
index 5fc90b513af..0d459e33abf 100644
--- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js
+++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js
@@ -20,6 +20,7 @@ openerp.hr_timesheet_sheet = function(instance) {
});
this.on("change:sheets", this, this.update_sheets);
this.res_o2m_drop = new instance.web.DropMisordered();
+ this.render_drop = new instance.web.DropMisordered();
this.description_line = _t("No description");
},
query_sheets: function() {
@@ -65,17 +66,21 @@ openerp.hr_timesheet_sheet = function(instance) {
start = start.clone().addDays(1);
}
// group by account
- self.accounts = _(this.get("sheets")).chain().map(function(el) {
+ self.accounts = _(this.get("sheets")).chain()
+ .map(function(el) {
// much simpler to use only the id in all cases
if (typeof(el.account_id) === "object")
el.account_id = el.account_id[0];
- }).groupBy("account_id")
+ return el;
+ })
+ .groupBy("account_id")
.map(function(lines, account_id) {
// group by days
account_id = account_id === "false" ? false : Number(account_id);
var index = _.groupBy(lines, "date");
var days = _.map(self.dates, function(date) {
var day = {day: date, lines: index[instance.web.date_to_str(date)] || []};
+ // add line where we will insert/remove hours
var to_add = _.find(day.lines, function(line) { return line.name === self.description_line });
if (to_add) {
day.lines = _.without(to_add);
@@ -85,17 +90,38 @@ openerp.hr_timesheet_sheet = function(instance) {
name: self.description_line,
unit_amount: 0,
date: instance.web.date_to_str(date),
- account_id: k === "false" ? false : Number(account_id),
+ account_id: account_id,
});
}
+ return day;
});
return {account: account_id, days: days};
}).sortBy(function(account) {
return account.account;
}).value();
- debugger;
- //TODO: handle the account_id name_get problem !
+ // we need the name_get of the analytic accounts
+ return this.res_o2m_drop.add(new instance.web.Model("account.analytic.account").call("name_get", [_.pluck(self.accounts, "account")])
+ .pipe(function(result) {
+ self.account_names = {};
+ _.each(result, function(el) {
+ self.account_names[el[0]] = el[1];
+ });
+ //real rendering
+ self.$el.html(QWeb.render("hr_timesheet_sheet.WeeklyTimesheet", {widget: self}));
+ _.each(self.accounts, function(account) {
+ var total = 0;
+ _.each(_.range(account.days.length), function(day_count) {
+ var line_total = 0;
+ _.each(account.days[day_count].lines, function(line) {
+ line_total += line.unit_amount;
+ });
+ self.$('[data-account="' + account.account + '"][data-day-count="' + day_count + '"]').val(line_total);
+ total += line_total;
+ });
+ self.$('[data-account-total="' + account.account + '"]').html(total);
+ });
+ }));
},
});
diff --git a/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml b/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml
index 2f4063aed01..cb633543cec 100644
--- a/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml
+++ b/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml
@@ -2,8 +2,26 @@
<templates>
<t t-name="hr_timesheet_sheet.WeeklyTimesheet">
- <div>
- Yoh!
+ <div class="oe_timesheet_weekly">
+ <table>
+ <tr>
+ <th> </th>
+ <th t-foreach="widget.dates" t-as="date">
+ <t t-esc="date.toString('ddd')"/><br />
+ <t t-esc="date.toString('MMM d')"/>
+ </th>
+ <th>Total</th>
+ </tr>
+ <tr t-foreach="widget.accounts" t-as="account">
+ <td><t t-esc="widget.account_names[account.account]"/></td>
+ <t t-set="day_count" t-value="0"/>
+ <td t-foreach="account.days" t-as="day">
+ <input t-att-data-account="account.account" t-att-data-day-count="day_count" type="text"/>
+ <t t-set="day_count" t-value="day_count + 1"/>
+ </td>
+ <td t-att-data-account-total="account.account"> </td>
+ </tr>
+ </table>
</div>
</t>
</templates> \ No newline at end of file