Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] event_registration_sale_line_contract: Fecha inicio/fin en part…
…icipantes, y lineas de contracto
- Loading branch information
1 parent
56f07a6
commit 4412a20
Showing
11 changed files
with
116 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import event_registration | ||
from . import sale_order | ||
from . import sale_order_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
event_registration_sale_line_contract/models/sale_order_line.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = 'sale.order.line' | ||
|
||
def _update_event_registration_contract_line(self): | ||
for line in self: | ||
cond = [('event_id', '=', line.event_id.id), | ||
('event_ticket_id', '=', line.event_ticket_id.id), | ||
('sale_order_line_id', '=', line.id), | ||
('contract_line_id', '=', False)] | ||
registration = self.env['event.registration'].search(cond) | ||
if registration and len(registration) == 1: | ||
registration.contract_line_id = line.contract_line_id.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from . import event_registration | ||
from . import contract_line | ||
from . import sale_order_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models | ||
|
||
|
||
class ContractLine(models.Model): | ||
_inherit = 'contract.line' | ||
|
||
def write(self, vals): | ||
result = super(ContractLine, self).write(vals) | ||
if 'no_update_event_reg_dates' not in self.env.context: | ||
if (('date_start' in vals and vals.get('date_start', False)) or | ||
('date_end' in vals and vals.get('date_end', False))): | ||
lines = self.filtered( | ||
lambda x: x.sale_order_id and x.sale_order_line_id and | ||
x.sale_order_line_id.event_id and | ||
x.sale_order_line_id.event_ticket_id) | ||
if lines: | ||
lines.update_dates_in_event_registration(vals) | ||
return result | ||
|
||
def update_dates_in_event_registration(self, vals): | ||
for line in self: | ||
cond = [('contract_line_id', '=', line.id)] | ||
registration = self.env['event.registration'].search(cond) | ||
if registration and len(registration) == 1: | ||
vals2 = {} | ||
if 'date_start' in vals and vals.get('date_start', False): | ||
vals2['date_start'] = vals.get('date_start') | ||
if 'date_end' in vals and vals.get('date_end', False): | ||
vals2['date_end'] = vals.get('date_end') | ||
registration.with_context( | ||
no_update_contract_line_dates=True).write(vals2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2021 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = 'sale.order.line' | ||
|
||
def _update_event_registration_contract_line(self): | ||
result = super( | ||
SaleOrderLine, self)._update_event_registration_contract_line() | ||
for line in self: | ||
cond = [('contract_line_id', '=', line.contract_line_id.id)] | ||
registration = self.env['event.registration'].search(cond) | ||
if registration and len(registration) == 1: | ||
vals = {} | ||
if registration.date_start: | ||
vals['date_start'] = registration.date_start | ||
if registration.date_end: | ||
vals['date_end'] = registration.date_end | ||
if vals: | ||
registration.contract_line_id.with_context( | ||
no_update_event_reg_dates=True).write(vals) | ||
return result |