diff --git a/bemade_fsm/__manifest__.py b/bemade_fsm/__manifest__.py
index 79dc6d3..671cb2c 100644
--- a/bemade_fsm/__manifest__.py
+++ b/bemade_fsm/__manifest__.py
@@ -37,6 +37,7 @@
'worksheet',
'industry_fsm_stock',
'industry_fsm_report',
+ 'industry_fsm_sale_report',
'bemade_partner_root_ancestor',
'mail',
],
@@ -50,7 +51,8 @@
'views/menus.xml',
'views/task_views.xml',
'views/sale_order_views.xml',
- 'reports/worksheet_templates.xml',
+ 'reports/worksheet_custom_report_templates.xml',
+ 'reports/worksheet_custom_reports.xml',
],
'assets': {
'web.assets_tests': [
diff --git a/bemade_fsm/models/sale_order.py b/bemade_fsm/models/sale_order.py
index 6628e77..e74054e 100644
--- a/bemade_fsm/models/sale_order.py
+++ b/bemade_fsm/models/sale_order.py
@@ -36,6 +36,16 @@ class SaleOrder(models.Model):
inverse_name="sale_order_id",
readonly=False)
+ @api.depends('order_line.task_id')
+ def get_relevant_order_lines(self, task_id):
+ self.ensure_one()
+ linked_lines = self.order_line.filtered(lambda l: l.task_id == task_id
+ or l == task_id.visit_id.so_section_id)
+ visit_lines = linked_lines.filtered(lambda l: l.visit_id)
+ for line in visit_lines:
+ linked_lines |= line.get_section_line_ids()
+ return linked_lines
+
@api.depends('order_line.equipment_ids')
def _compute_summary_equipment_ids(self):
for rec in self:
@@ -212,7 +222,7 @@ class SaleOrderLine(models.Model):
'visit_id': self.visit_id.id,
'date_deadline': self.visit_id.approx_date,
'planned_hours': self.task_duration,
- 'user_ids': False, # Force to empty or it uses the current user
+ 'user_ids': False, # Force to empty or it uses the current user
})
return task
diff --git a/bemade_fsm/models/task.py b/bemade_fsm/models/task.py
index 94a9642..dee8859 100644
--- a/bemade_fsm/models/task.py
+++ b/bemade_fsm/models/task.py
@@ -49,12 +49,14 @@ class Task(models.Model):
visit_id = fields.Many2one(comodel_name='bemade_fsm.visit')
- # user_id = fields.Many2one('res.users', compute='_compute_user_id')
- #
- # @api.depends('user_ids')
- # def _compute_user_id(self):
- # for rec in self:
- # rec.user_id = rec.user_ids and rec.user_ids[0] or 0
+ relevant_order_lines = fields.Many2many(comodel_name='sale.order.line',
+ store=False,
+ compute='_compute_relevant_order_lines',)
+ @api.depends('sale_order_id')
+ def _compute_relevant_order_lines(self):
+ for rec in self:
+ rec.relevant_order_lines = rec.sale_order_id \
+ and rec.sale_order_id.get_relevant_order_lines(rec)
def _get_closed_stage_by_project(self):
""" Gets the stage representing completed tasks for each project in
@@ -176,3 +178,7 @@ class Task(models.Model):
rec.name += f" ({template.name})"
else:
rec.name = f"{template.name or rec.sale_line_id.name or rec.name}"
+
+ @property
+ def root_ancestor(self):
+ return self.parent_id and self.parent_id.root_ancestor or self
diff --git a/bemade_fsm/reports/worksheet_custom_report_templates.xml b/bemade_fsm/reports/worksheet_custom_report_templates.xml
new file mode 100644
index 0000000..8606cba
--- /dev/null
+++ b/bemade_fsm/reports/worksheet_custom_report_templates.xml
@@ -0,0 +1,189 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Time & Material
+
+
+
+
+ | Description |
+ Ordered |
+ Delivered |
+ Unit Price |
+
+ Disc.%
+ |
+
+
+ Amount
+
+ Total Price
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+ Section Subtotal
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ | Untaxed amount |
+
+
+ |
+
+
+ | Taxes |
+
+
+ |
+
+
+ | Total |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bemade_fsm/reports/worksheet_custom_reports.xml b/bemade_fsm/reports/worksheet_custom_reports.xml
new file mode 100644
index 0000000..bd39fb9
--- /dev/null
+++ b/bemade_fsm/reports/worksheet_custom_reports.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ Work Order Report (PDF)
+ bemade_fsm.work_order
+ bemade_fsm.work_order
+ '%s Work Order %s' % (time.strftime('%Y-%m-%d'), object.name)
+ qweb-html
+
+
+
\ No newline at end of file