diff --git a/sale_crm_school/__manifest__.py b/sale_crm_school/__manifest__.py
index c2d5f5c2..da8ad103 100644
--- a/sale_crm_school/__manifest__.py
+++ b/sale_crm_school/__manifest__.py
@@ -3,7 +3,7 @@
{
"name": "Opportunity to Quotation for School",
- "version": "12.0.1.2.0",
+ "version": "12.0.1.3.0",
"category": "Sales",
"license": "AGPL-3",
"author": "AvanzOSC",
@@ -19,7 +19,6 @@
"views/sale_order_view.xml",
"views/crm_lead_view.xml",
"views/crm_lead_future_student_view.xml",
- "views/product_category_view.xml",
"views/education_course_view.xml",
"views/sale_order_template_view.xml",
"views/product_view.xml",
diff --git a/sale_crm_school/i18n/es.po b/sale_crm_school/i18n/es.po
index 83358a5a..3e34ac99 100644
--- a/sale_crm_school/i18n/es.po
+++ b/sale_crm_school/i18n/es.po
@@ -68,12 +68,6 @@ msgstr "Iniciativa/Oportunidad"
msgid "Opportunity"
msgstr "Oportunidad"
-#. module: sale_crm_school
-#: model:ir.model.fields,field_description:sale_crm_school.field_product_category__originator_id
-#: model_terms:ir.ui.view,arch_db:sale_crm_school.product_category_search_view_inh_sale_crm_school
-msgid "Originator"
-msgstr "Ordenante"
-
#. module: sale_crm_school
#: model:ir.model,name:sale_crm_school.model_product_category
msgid "Product Category"
diff --git a/sale_crm_school/i18n/sale_crm_school.pot b/sale_crm_school/i18n/sale_crm_school.pot
index 4c122970..c0d5c90f 100644
--- a/sale_crm_school/i18n/sale_crm_school.pot
+++ b/sale_crm_school/i18n/sale_crm_school.pot
@@ -68,12 +68,6 @@ msgstr ""
msgid "Opportunity"
msgstr ""
-#. module: sale_crm_school
-#: model:ir.model.fields,field_description:sale_crm_school.field_product_category__originator_id
-#: model_terms:ir.ui.view,arch_db:sale_crm_school.product_category_search_view_inh_sale_crm_school
-msgid "Originator"
-msgstr ""
-
#. module: sale_crm_school
#: model:ir.model,name:sale_crm_school.model_product_category
msgid "Product Category"
diff --git a/sale_crm_school/models/__init__.py b/sale_crm_school/models/__init__.py
index 5699e29d..2b6d4cae 100644
--- a/sale_crm_school/models/__init__.py
+++ b/sale_crm_school/models/__init__.py
@@ -1,5 +1,4 @@
from . import sale_order
from . import crm_lead
-from . import product_category
from . import education_course
from . import product
diff --git a/sale_crm_school/models/crm_lead.py b/sale_crm_school/models/crm_lead.py
index b889ac73..ef121564 100644
--- a/sale_crm_school/models/crm_lead.py
+++ b/sale_crm_school/models/crm_lead.py
@@ -44,20 +44,22 @@ def _get_vals_for_sale_order(self, future):
'opportunity_id': self.id,
'child_id': future.child_id.id,
'course_id': future.course_id.id,
- 'school_id': future.school_id.id,
- 'sale_order_template_id':
- future.course_id.sale_order_template_id.id}
+ 'school_id': future.school_id.id}
if future.academic_year_id:
vals['academic_year_id'] = future.academic_year_id.id
+ cond = [('school_id', '=', future.school_id.id),
+ ('course_id', '=', future.course_id.id)]
+ template = self.env['sale.order.template'].search(cond, limit=1)
+ if template:
+ vals['sale_order_template_id'] = template.id
return vals
@api.multi
def _put_payer_information_in_sale_order(self, future, sale):
for line in sale.order_line:
vals = {}
- if line.product_id.categ_id.originator_id:
- vals['originator_id'] = (
- line.product_id.categ_id.originator_id)
+ if line.product_id.company_id:
+ vals['originator_id'] = line.product_id.company_id.id
payers = future.child_id.mapped('child2_ids').filtered(
lambda l: l.payer)
vals2 = []
diff --git a/sale_crm_school/models/product.py b/sale_crm_school/models/product.py
index 5dafe0a1..c27321b1 100644
--- a/sale_crm_school/models/product.py
+++ b/sale_crm_school/models/product.py
@@ -8,5 +8,5 @@ class ProductTemplate(models.Model):
_inherit = 'product.template'
center_id = fields.Many2one(
- relation='res.partner', string='Center', readonly=True,
- related='categ_id.center_id', store=True)
+ comodel_name='res.partner', string='Center',
+ domain=[('educational_category', '=', 'school')])
diff --git a/sale_crm_school/models/product_category.py b/sale_crm_school/models/product_category.py
deleted file mode 100644
index abce3f2b..00000000
--- a/sale_crm_school/models/product_category.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2019 Alfredo de la Fuente - AvanzOSC
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import models, fields
-
-
-class ProductCategory(models.Model):
- _inherit = 'product.category'
-
- originator_id = fields.Many2one(
- comodel_name='res.company', string='Originator')
- center_id = fields.Many2one(
- comodel_name='res.partner', string='Center',
- domain=[('educational_category', '=', 'school')])
diff --git a/sale_crm_school/models/sale_order.py b/sale_crm_school/models/sale_order.py
index 7d7f4238..25b7da1e 100644
--- a/sale_crm_school/models/sale_order.py
+++ b/sale_crm_school/models/sale_order.py
@@ -39,5 +39,16 @@ class SaleOrderLine(models.Model):
class SaleOrderTemplate(models.Model):
_inherit = 'sale.order.template'
+ school_id = fields.Many2one(
+ comodel_name='res.partner', string='School',
+ domain=[('educational_category', '=', 'school')])
course_id = fields.Many2one(
comodel_name='education.course', string='Course')
+
+
+class SaleOrderTemplateLine(models.Model):
+ _inherit = "sale.order.template.line"
+
+ company_id = fields.Many2one(
+ string='Company', comodel_name='res.company',
+ related='product_id.company_id', store=True)
diff --git a/sale_crm_school/tests/test_sale_crm_school.py b/sale_crm_school/tests/test_sale_crm_school.py
index a35b32fd..2f56da35 100644
--- a/sale_crm_school/tests/test_sale_crm_school.py
+++ b/sale_crm_school/tests/test_sale_crm_school.py
@@ -53,7 +53,9 @@ def setUp(self):
'description': 'Course 1'}
self.education_course = self.education_course_model.create(
education_course_vals)
- sale_template.course_id = self.education_course.id
+ sale_template.write(
+ {'course_id': self.education_course.id,
+ 'school_id': self.school.id})
date_from = "{}-01-01".format(
fields.Date.from_string(fields.Date.today()).year)
date_from = fields.Date.from_string(date_from)
diff --git a/sale_crm_school/views/product_category_view.xml b/sale_crm_school/views/product_category_view.xml
deleted file mode 100644
index 9bc6a94c..00000000
--- a/sale_crm_school/views/product_category_view.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- product.category
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- product.category
-
-
-
-
-
-
-
-
-
-
- product.category
-
-
-
-
-
-
-
-
-
-
diff --git a/sale_crm_school/views/product_view.xml b/sale_crm_school/views/product_view.xml
index 2dbb5862..4471ead0 100644
--- a/sale_crm_school/views/product_view.xml
+++ b/sale_crm_school/views/product_view.xml
@@ -3,6 +3,16 @@
product.template
+
+
+
+
+
+
+
+
+ product.template
+
diff --git a/sale_crm_school/views/sale_order_template_view.xml b/sale_crm_school/views/sale_order_template_view.xml
index fdb95e60..c00ad5e7 100644
--- a/sale_crm_school/views/sale_order_template_view.xml
+++ b/sale_crm_school/views/sale_order_template_view.xml
@@ -5,8 +5,15 @@
+
+
+
+
+
+
+
@@ -14,6 +21,7 @@
+
@@ -23,6 +31,7 @@
+