Skip to content

Commit

Permalink
Merge pull request #47 from alfredoavanzosc/sale-addons12-sale_crm_sc…
Browse files Browse the repository at this point in the history
…hool

[IMP] sale_crm_school: Coger ordenante del producto no del la categoría
  • Loading branch information
alfredoavanzosc authored Jul 24, 2019
2 parents edecec2 + b65d52b commit 8cfaa23
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 79 deletions.
3 changes: 1 addition & 2 deletions sale_crm_school/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions sale_crm_school/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 0 additions & 6 deletions sale_crm_school/i18n/sale_crm_school.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion sale_crm_school/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from . import sale_order
from . import crm_lead
from . import product_category
from . import education_course
from . import product
14 changes: 8 additions & 6 deletions sale_crm_school/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions sale_crm_school/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')])
13 changes: 0 additions & 13 deletions sale_crm_school/models/product_category.py

This file was deleted.

11 changes: 11 additions & 0 deletions sale_crm_school/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion sale_crm_school/tests/test_sale_crm_school.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 0 additions & 42 deletions sale_crm_school/views/product_category_view.xml

This file was deleted.

10 changes: 10 additions & 0 deletions sale_crm_school/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
<record id="product_template_only_form_view" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="center_id"/>
</field>
</field>
</record>

<record id="product_template_tree_view" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view" />
<field name="arch" type="xml">
<field name="categ_id" position="after">
<field name="center_id"/>
Expand Down
9 changes: 9 additions & 0 deletions sale_crm_school/views/sale_order_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@
<field name="inherit_id" ref="sale_management.sale_order_template_view_form" />
<field name="arch" type="xml">
<div id="number_of_days" position="after">
<field name="school_id" />
<field name="course_id" />
</div>
<xpath expr="//field[@name='sale_order_template_line_ids']/form//field[@name='product_id']" position="before">
<field name="company_id" readonly="1"/>
</xpath>
<xpath expr="//field[@name='sale_order_template_line_ids']/tree//field[@name='product_id']" position="before">
<field name="company_id" />
</xpath>
</field>
</record>
<record id="sale_order_view_tree" model="ir.ui.view">
<field name="model">sale.order.template</field>
<field name="inherit_id" ref="sale_management.sale_order_template_view_tree" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="school_id" />
<field name="course_id" />
</field>
</field>
Expand All @@ -23,6 +31,7 @@
<field name="inherit_id" ref="sale_management.sale_order_template_view_search" />
<field name="arch" type="xml">
<filter name="inactive" position="after">
<field name="school_id" />
<field name="course_id" />
</filter>
</field>
Expand Down

0 comments on commit 8cfaa23

Please sign in to comment.