Compare commits
4 Commits
f5cfe50c6c
...
a712e52d2c
Author | SHA1 | Date |
---|---|---|
oscar alvarez | a712e52d2c | |
oscar alvarez | 823c361237 | |
oscar alvarez | cca15eedc8 | |
oscar alvarez | e877de1d75 |
|
@ -87,7 +87,8 @@ def register():
|
||||||
stock.Move,
|
stock.Move,
|
||||||
sale.InvoiceIncomeDailyStart,
|
sale.InvoiceIncomeDailyStart,
|
||||||
sale.Sale,
|
sale.Sale,
|
||||||
sale.SaleTransferFolioStart,
|
sale.SaleLine,
|
||||||
|
sale.SaleTransferStart,
|
||||||
service.Service,
|
service.Service,
|
||||||
service.ServiceLine,
|
service.ServiceLine,
|
||||||
service.ServiceKind,
|
service.ServiceKind,
|
||||||
|
@ -159,7 +160,7 @@ def register():
|
||||||
room.Housekeeping,
|
room.Housekeeping,
|
||||||
housekeeping.HousekeepingSchedule,
|
housekeeping.HousekeepingSchedule,
|
||||||
sale.InvoiceIncomeDaily,
|
sale.InvoiceIncomeDaily,
|
||||||
sale.SaleTransferFolio,
|
sale.SaleTransfer,
|
||||||
party.CreateGuest,
|
party.CreateGuest,
|
||||||
operation.NightAuditWizard,
|
operation.NightAuditWizard,
|
||||||
siat.SiatSyncWizard,
|
siat.SiatSyncWizard,
|
||||||
|
|
41
booking.py
41
booking.py
|
@ -2273,13 +2273,9 @@ class StatementPaymentForm(ModelView):
|
||||||
'Statement Payment Form'
|
'Statement Payment Form'
|
||||||
__name__ = 'hotel.payment_form.start'
|
__name__ = 'hotel.payment_form.start'
|
||||||
statement = fields.Many2One('account.statement', 'Statement',
|
statement = fields.Many2One('account.statement', 'Statement',
|
||||||
required=True, domain=['OR', [
|
required=True, domain=[
|
||||||
('create_uid.login', '=', Eval('user')),
|
('id', 'in', Eval('statements')),
|
||||||
('state', '=', 'draft')
|
])
|
||||||
], [
|
|
||||||
Eval('user') == 'admin',
|
|
||||||
('state', '=', 'draft'),
|
|
||||||
]])
|
|
||||||
amount_to_pay = fields.Numeric('Amount to Pay', required=True,
|
amount_to_pay = fields.Numeric('Amount to Pay', required=True,
|
||||||
digits=(16, Eval('currency_digits', 2)),
|
digits=(16, Eval('currency_digits', 2)),
|
||||||
depends=['currency_digits'])
|
depends=['currency_digits'])
|
||||||
|
@ -2301,22 +2297,18 @@ class StatementPaymentForm(ModelView):
|
||||||
party = fields.Many2One('party.party', 'Party', domain=[
|
party = fields.Many2One('party.party', 'Party', domain=[
|
||||||
('id', 'in', Eval('parties'))
|
('id', 'in', Eval('parties'))
|
||||||
], required=True)
|
], required=True)
|
||||||
user = fields.Many2One('res.user', 'User', states={'readonly': True})
|
|
||||||
require_voucher = fields.Boolean('Require Voucher', depends=['statement'])
|
require_voucher = fields.Boolean('Require Voucher', depends=['statement'])
|
||||||
parties = fields.Many2Many('party.party', None, None, 'Parties')
|
parties = fields.Many2Many('party.party', None, None, 'Parties')
|
||||||
folios = fields.Many2Many('hotel.folio', None, None, 'Folios')
|
folios = fields.Many2Many('hotel.folio', None, None, 'Folios')
|
||||||
|
statements = fields.Many2Many('account.statement', None, None,
|
||||||
|
'Statements')
|
||||||
|
|
||||||
@classmethod
|
@staticmethod
|
||||||
def default_require_voucher(cls):
|
def default_require_voucher():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@staticmethod
|
||||||
def default_user(cls):
|
def default_kind():
|
||||||
user = Pool().get('res.user')(Transaction().user)
|
|
||||||
return user.id
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def default_kind(cls):
|
|
||||||
model = Transaction().context['active_model']
|
model = Transaction().context['active_model']
|
||||||
if model == "hotel.folio":
|
if model == "hotel.folio":
|
||||||
return "folio"
|
return "folio"
|
||||||
|
@ -2345,8 +2337,11 @@ class WizardStatementPayment(Wizard):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Booking = pool.get('hotel.booking')
|
Booking = pool.get('hotel.booking')
|
||||||
Folio = pool.get('hotel.folio')
|
Folio = pool.get('hotel.folio')
|
||||||
|
user = pool.get('res.user')(Transaction().user)
|
||||||
|
Statement = pool.get('account.statement')
|
||||||
model = Transaction().context['active_model']
|
model = Transaction().context['active_model']
|
||||||
active_id = Transaction().context['active_id']
|
active_id = Transaction().context['active_id']
|
||||||
|
user = pool.get('res.user')(Transaction().user)
|
||||||
parties_ids = []
|
parties_ids = []
|
||||||
folios_ids = []
|
folios_ids = []
|
||||||
folio_id = None
|
folio_id = None
|
||||||
|
@ -2381,6 +2376,17 @@ class WizardStatementPayment(Wizard):
|
||||||
folio.booking.responsible_payment == 'holder':
|
folio.booking.responsible_payment == 'holder':
|
||||||
pending_to_pay = folio.booking.pending_to_pay
|
pending_to_pay = folio.booking.pending_to_pay
|
||||||
|
|
||||||
|
if user.login == 'admin':
|
||||||
|
dom = [
|
||||||
|
('state', '=', 'draft'),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
dom = [
|
||||||
|
('create_uid', '=', user.id),
|
||||||
|
('state', '=', 'draft'),
|
||||||
|
]
|
||||||
|
statements = Statement.search_read(dom, fields_names=['id'])
|
||||||
|
statement_ids = [st['id'] for st in statements]
|
||||||
return {
|
return {
|
||||||
'currency_digits': 2,
|
'currency_digits': 2,
|
||||||
'party': party_id,
|
'party': party_id,
|
||||||
|
@ -2388,6 +2394,7 @@ class WizardStatementPayment(Wizard):
|
||||||
'parties': parties_ids,
|
'parties': parties_ids,
|
||||||
'folios': folios_ids,
|
'folios': folios_ids,
|
||||||
'amount_to_pay': pending_to_pay,
|
'amount_to_pay': pending_to_pay,
|
||||||
|
'statements': statement_ids,
|
||||||
'kind': kind,
|
'kind': kind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
folio.py
2
folio.py
|
@ -1677,7 +1677,7 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_origin(cls):
|
def _get_origin(cls):
|
||||||
'Return list of Model names for origin Reference'
|
'Return list of Model names for origin Reference'
|
||||||
return ['sale.sale']
|
return ['sale.sale', 'sale.line']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_origin(cls):
|
def get_origin(cls):
|
||||||
|
|
15
hotel.xml
15
hotel.xml
|
@ -112,20 +112,5 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="sequence_type" ref="sequence_type_hotel"/>
|
<field name="sequence_type" ref="sequence_type_hotel"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="sale_transfer_to_folio_start_view_form">
|
|
||||||
<field name="model">sale.transfer_to_folio.start</field>
|
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="name">sale_transfer_to_folio_form</field>
|
|
||||||
</record>
|
|
||||||
<record model="ir.action.wizard" id="act_sale_transfer_to_folio">
|
|
||||||
<field name="name">Transfer to Folio</field>
|
|
||||||
<field name="wiz_name">sale.transfer_to_folio</field>
|
|
||||||
</record>
|
|
||||||
<record model="ir.action.keyword" id="act_sale_transfer_to_folio_keyword">
|
|
||||||
<field name="keyword">form_action</field>
|
|
||||||
<field name="model">sale.sale,-1</field>
|
|
||||||
<field name="action" ref="act_sale_transfer_to_folio"/>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
93
sale.py
93
sale.py
|
@ -5,6 +5,7 @@ from decimal import Decimal
|
||||||
|
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
from trytond.pyson import Eval
|
||||||
from trytond.report import Report
|
from trytond.report import Report
|
||||||
from trytond.model import ModelView, fields
|
from trytond.model import ModelView, fields
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
@ -17,14 +18,17 @@ _ZERO = Decimal(0)
|
||||||
|
|
||||||
class Sale(metaclass=PoolMeta):
|
class Sale(metaclass=PoolMeta):
|
||||||
__name__ = 'sale.sale'
|
__name__ = 'sale.sale'
|
||||||
folio = fields.Many2One('hotel.folio', 'Folio', states={
|
# folio = fields.Many2One('hotel.folio', 'Folio', states={
|
||||||
'readonly': True,
|
# 'readonly': True,
|
||||||
})
|
# })
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
super(Sale, cls).__setup__()
|
super(Sale, cls).__setup__()
|
||||||
cls.state.selection.append(('transfered', 'Transfered'))
|
# _states = {
|
||||||
|
# 'readonly': Eval('state') != 'draft',
|
||||||
|
# }
|
||||||
|
cls.state.selection.append(('transferred', 'Transferred'))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def transfer_to_folio(cls, sale_id, folio_id):
|
def transfer_to_folio(cls, sale_id, folio_id):
|
||||||
|
@ -52,17 +56,54 @@ class Sale(metaclass=PoolMeta):
|
||||||
'status': 'pending',
|
'status': 'pending',
|
||||||
'origin': f'sale.sale,{sale_id}',
|
'origin': f'sale.sale,{sale_id}',
|
||||||
})
|
})
|
||||||
Charge.create(to_create)
|
charges_ids = Charge.create(to_create)
|
||||||
|
|
||||||
|
# 'folio': folio_id,
|
||||||
cls.write([sale], {
|
cls.write([sale], {
|
||||||
'state': 'transfered',
|
'state': 'transferred',
|
||||||
'folio': folio_id,
|
|
||||||
'invoice_method': 'manual',
|
'invoice_method': 'manual',
|
||||||
'shipment_method': 'manual',
|
'shipment_method': 'manual',
|
||||||
'reference': folio.booking.number,
|
'reference': folio.booking.number,
|
||||||
})
|
})
|
||||||
|
# FIXME: Add stock moves
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def transfer_to_sale(cls, sale_id, target_sale_id):
|
||||||
|
Line = Pool().get('sale.line')
|
||||||
|
sale, = cls.browse([sale_id])
|
||||||
|
target, = cls.browse([target_sale_id])
|
||||||
|
for line in sale.lines:
|
||||||
|
nwline, = Line.copy([line])
|
||||||
|
nwline.sale = target.id
|
||||||
|
nwline.origin = f'sale.line,{line.id}'
|
||||||
|
nwline.save()
|
||||||
|
cls.write([sale], {
|
||||||
|
'state': 'transferred',
|
||||||
|
'invoice_method': 'manual',
|
||||||
|
'shipment_method': 'manual',
|
||||||
|
'reference': sale.number,
|
||||||
|
})
|
||||||
|
# FIXME: Add stock moves
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
|
|
||||||
|
class SaleLine(metaclass=PoolMeta):
|
||||||
|
__name__ = 'sale.line'
|
||||||
|
origin = fields.Reference('Origin', selection='get_origin', readonly=True)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_origin(cls):
|
||||||
|
'Return list of Model names for origin Reference'
|
||||||
|
return ['sale.line']
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_origin(cls):
|
||||||
|
Model = Pool().get('ir.model')
|
||||||
|
get_name = Model.get_name
|
||||||
|
models = cls._get_origin()
|
||||||
|
return [(None, '')] + [(m, get_name(m)) for m in models]
|
||||||
|
|
||||||
|
|
||||||
class InvoiceIncomeDailyStart(ModelView):
|
class InvoiceIncomeDailyStart(ModelView):
|
||||||
'Invoice Income Daily Start'
|
'Invoice Income Daily Start'
|
||||||
|
@ -91,7 +132,7 @@ class InvoiceIncomeDaily(Wizard):
|
||||||
'hotel.invoice_income_daily_start_view_form', [
|
'hotel.invoice_income_daily_start_view_form', [
|
||||||
Button('Cancel', 'end', 'tryton-cancel'),
|
Button('Cancel', 'end', 'tryton-cancel'),
|
||||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||||
])
|
])
|
||||||
print_ = StateReport('hotel.invoice_income_daily_report')
|
print_ = StateReport('hotel.invoice_income_daily_report')
|
||||||
|
|
||||||
def do_print_(self, action):
|
def do_print_(self, action):
|
||||||
|
@ -275,22 +316,34 @@ class InvoiceSimplifiedReport(Report):
|
||||||
return report_context
|
return report_context
|
||||||
|
|
||||||
|
|
||||||
class SaleTransferFolioStart(ModelView):
|
class SaleTransferStart(ModelView):
|
||||||
'Sale Transfer Folio Start'
|
'Sale Transfer Start'
|
||||||
__name__ = 'sale.transfer_to_folio.start'
|
__name__ = 'sale.transfer.start'
|
||||||
|
kind = fields.Selection([
|
||||||
|
('folio', 'Folio'),
|
||||||
|
('sale', 'Sale'),
|
||||||
|
], 'Kind', required=True)
|
||||||
folio = fields.Many2One('hotel.folio', 'Folio', domain=[
|
folio = fields.Many2One('hotel.folio', 'Folio', domain=[
|
||||||
('registration_state', '=', 'check_in'),
|
('registration_state', '=', 'check_in'),
|
||||||
('arrival_date', '<=', date.today()),
|
('arrival_date', '<=', date.today()),
|
||||||
('departure_date', '>=', date.today()),
|
('departure_date', '>=', date.today()),
|
||||||
])
|
], states={
|
||||||
|
'invisible': Eval('kind') != 'folio'
|
||||||
|
})
|
||||||
|
sale = fields.Many2One('sale.sale', 'Sale', domain=[
|
||||||
|
('state', '=', 'draft'),
|
||||||
|
('number', '!=', None),
|
||||||
|
], states={
|
||||||
|
'invisible': Eval('kind') != 'sale'
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class SaleTransferFolio(Wizard):
|
class SaleTransfer(Wizard):
|
||||||
'Sale Transfer Folio'
|
'Sale Transfer'
|
||||||
__name__ = 'sale.transfer_to_folio'
|
__name__ = 'sale.transfer'
|
||||||
start = StateView(
|
start = StateView(
|
||||||
'sale.transfer_to_folio.start',
|
'sale.transfer.start',
|
||||||
'hotel.sale_transfer_to_folio_start_view_form', [
|
'hotel.sale_transfer_start_view_form', [
|
||||||
Button('Cancel', 'end', 'tryton-cancel'),
|
Button('Cancel', 'end', 'tryton-cancel'),
|
||||||
Button('Ok', 'accept', 'tryton-ok', default=True),
|
Button('Ok', 'accept', 'tryton-ok', default=True),
|
||||||
])
|
])
|
||||||
|
@ -299,5 +352,9 @@ class SaleTransferFolio(Wizard):
|
||||||
def transition_accept(self):
|
def transition_accept(self):
|
||||||
Sale = Pool().get('sale.sale')
|
Sale = Pool().get('sale.sale')
|
||||||
sale_id = Transaction().context['active_id']
|
sale_id = Transaction().context['active_id']
|
||||||
Sale.transfer_to_folio(sale_id, self.start.folio.id)
|
if self.start.kind == 'folio':
|
||||||
|
Sale.transfer_to_folio(sale_id, self.start.folio.id)
|
||||||
|
else:
|
||||||
|
Sale.transfer_to_sale(sale_id, self.start.sale.id)
|
||||||
|
|
||||||
return 'end'
|
return 'end'
|
||||||
|
|
22
sale.xml
22
sale.xml
|
@ -3,10 +3,15 @@
|
||||||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
<data>
|
<data>
|
||||||
<record model="ir.ui.view" id="sale_view_form">
|
<!-- <record model="ir.ui.view" id="sale_view_form">
|
||||||
<field name="model">sale.sale</field>
|
<field name="model">sale.sale</field>
|
||||||
<field name="inherit" ref="sale.sale_view_form"/>
|
<field name="inherit" ref="sale.sale_view_form"/>
|
||||||
<field name="name">sale_form</field>
|
<field name="name">sale_form</field>
|
||||||
|
</record> -->
|
||||||
|
<record model="ir.ui.view" id="sale_line_view_form">
|
||||||
|
<field name="model">sale.line</field>
|
||||||
|
<field name="inherit" ref="sale.sale_line_view_form"/>
|
||||||
|
<field name="name">sale_line_form</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.action.report" id="report_invoice_income_daily">
|
<record model="ir.action.report" id="report_invoice_income_daily">
|
||||||
|
@ -27,5 +32,20 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
||||||
<menuitem parent="hotel.menu_reporting" id="menu_invoice_income_daily"
|
<menuitem parent="hotel.menu_reporting" id="menu_invoice_income_daily"
|
||||||
action="wizard_print_invoice_income_daily"/>
|
action="wizard_print_invoice_income_daily"/>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="sale_transfer_start_view_form">
|
||||||
|
<field name="model">sale.transfer.start</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">sale_transfer_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.wizard" id="act_sale_transfer">
|
||||||
|
<field name="name">Transfer</field>
|
||||||
|
<field name="wiz_name">sale.transfer</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.keyword" id="act_sale_transfer_keyword">
|
||||||
|
<field name="keyword">form_action</field>
|
||||||
|
<field name="model">sale.sale,-1</field>
|
||||||
|
<field name="action" ref="act_sale_transfer"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=6.0.118
|
version=6.0.119
|
||||||
depends:
|
depends:
|
||||||
party
|
party
|
||||||
company
|
company
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<data>
|
<data>
|
||||||
<xpath
|
<xpath
|
||||||
expr="/form/notebook/page[@id='other']/field[@name='shipping_date']"
|
expr="/form/notebook/page[@id='general']/field[@name='description']"
|
||||||
position="after">
|
position="after">
|
||||||
<label name="folio"/>
|
<label name="origin"/>
|
||||||
<field name="folio"/>
|
<field name="origin"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
|
@ -2,6 +2,10 @@
|
||||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<form>
|
<form>
|
||||||
|
<label name="kind" />
|
||||||
|
<field name="kind" />
|
||||||
<label name="folio" />
|
<label name="folio" />
|
||||||
<field name="folio" />
|
<field name="folio" />
|
||||||
|
<label name="sale" />
|
||||||
|
<field name="sale" />
|
||||||
</form>
|
</form>
|
|
@ -15,7 +15,7 @@ copyright notices and license terms. -->
|
||||||
<field name="folio" widget="selection"/>
|
<field name="folio" widget="selection"/>
|
||||||
<label name="voucher"/>
|
<label name="voucher"/>
|
||||||
<field name="voucher"/>
|
<field name="voucher"/>
|
||||||
<field name="user" invisible="1"/>
|
<field name="statements" invisible="1"/>
|
||||||
<field name="require_voucher" invisible="1"/>
|
<field name="require_voucher" invisible="1"/>
|
||||||
<field name="parties" invisible="1"/>
|
<field name="parties" invisible="1"/>
|
||||||
<field name="folios" invisible="1"/>
|
<field name="folios" invisible="1"/>
|
||||||
|
|
Loading…
Reference in New Issue