Fix
This commit is contained in:
parent
642de10adf
commit
ea9fd1b5b0
|
@ -63,6 +63,8 @@ class Configuration(ModelSQL, ModelView):
|
|||
quarantine_rooms = fields.Numeric('Quarantine Rooms', digits=(2, 0), help='In days')
|
||||
booking_email_template = fields.Many2One('email.template',
|
||||
'Booking Template Email')
|
||||
storage_by_default = fields.Many2One('stock.location', 'Storage By Default',
|
||||
domain=[('type', '=', 'storage')], required=False)
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
|
|
142
folio.py
142
folio.py
|
@ -114,7 +114,8 @@ class Folio(ModelSQL, ModelView):
|
|||
invoice_line = fields.Many2One('account.invoice.line', 'Invoice Line')
|
||||
to_invoice = fields.Boolean('To Invoice', states={
|
||||
'invisible': Bool(Eval('invoice_line')),
|
||||
}, depends=['invoice_line'], help='Mark this checkbox if you want to invoice this item')
|
||||
}, depends=['invoice_line'],
|
||||
help='Mark this checkbox if you want to invoice this item')
|
||||
invoice = fields.Function(fields.Many2One('account.invoice', 'Invoice',
|
||||
depends=['invoice_line']), 'get_invoice')
|
||||
invoice_state = fields.Function(fields.Selection(
|
||||
|
@ -130,8 +131,6 @@ class Folio(ModelSQL, ModelView):
|
|||
room_amount = fields.Function(fields.Numeric('Room Amount',
|
||||
digits=(16, 2), depends=['nights_quantity', 'unit_price']
|
||||
), 'on_change_with_room_amount')
|
||||
# stock_moves = fields.Many2Many('hotel.folio-stock.move', 'folio',
|
||||
# 'move', 'Stock Moves', states={'readonly': True})
|
||||
channel = fields.Function(fields.Many2One('hotel.channel', 'Channel'),
|
||||
'get_channel')
|
||||
num_children = fields.Function(fields.Integer('Num. Children'),
|
||||
|
@ -878,111 +877,6 @@ class FolioGuest(ModelSQL, ModelView):
|
|||
cls.manage_party(data)
|
||||
|
||||
|
||||
class OperationMaintenance(Workflow, ModelSQL, ModelView):
|
||||
'Operation Maintenance'
|
||||
__name__ = 'hotel.operation.maintenance'
|
||||
operation = fields.Many2One('hotel.operation', 'Operation', states=STATES_MNT)
|
||||
room = fields.Many2One('hotel.room', 'Room', states=STATES_MNT, select=True,
|
||||
required=True)
|
||||
kind = fields.Selection([
|
||||
('maintenance', 'Maintenance'),
|
||||
], 'Kind', readonly=True, select=True)
|
||||
start_date = fields.Date('Start Date', states=STATES_MNT, required=True,
|
||||
select=True)
|
||||
end_date = fields.Date('End Date', states=STATES_MNT, required=True,
|
||||
select=True)
|
||||
description = fields.Text('Description', states=STATES_MNT, select=True)
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('confirmed', 'Confirmed'),
|
||||
('finished', 'Finished'),
|
||||
('cancelled', 'Canceled'),
|
||||
], 'State', readonly=True, select=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(OperationMaintenance, cls).__setup__()
|
||||
cls._transitions |= set((
|
||||
('draft', 'confirmed'),
|
||||
('draft', 'cancelled'),
|
||||
('confirmed', 'finished'),
|
||||
('confirmed', 'cancelled'),
|
||||
))
|
||||
cls._buttons.update({
|
||||
'cancel': {
|
||||
'invisible': ~Eval('state').in_(['draft', 'confirmed']),
|
||||
},
|
||||
'draft': {
|
||||
'invisible': Eval('state') != 'confirmed',
|
||||
},
|
||||
'confirm': {
|
||||
'invisible': Eval('state') != 'draft',
|
||||
},
|
||||
'finish': {
|
||||
'invisible': Eval('state') != 'confirmed',
|
||||
},
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def default_kind():
|
||||
return 'maintenance'
|
||||
|
||||
@staticmethod
|
||||
def default_state():
|
||||
return 'draft'
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('draft')
|
||||
def draft(cls, records):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('cancelled')
|
||||
def cancel(cls, records):
|
||||
for mant in records:
|
||||
mant.delete_operation()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('confirmed')
|
||||
def confirm(cls, records):
|
||||
for mant in records:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('finished')
|
||||
def finish(cls, records):
|
||||
for mant in records:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def write(cls, records, values):
|
||||
Room = Pool().get('hotel.room')
|
||||
for rec in records:
|
||||
if values.get('start_date') or values.get('end_date') or values.get('room'):
|
||||
start_date = values.get('start_date') or rec.start_date
|
||||
end_date = values.get('end_date') or rec.end_date
|
||||
room = Room(values.get('room') or rec.room)
|
||||
# Operation().check_dates(start_date, end_date, room, rec.operation)
|
||||
# rec.update_operation({
|
||||
# 'start_date': start_date,
|
||||
# 'end_date': end_date,
|
||||
# 'room': room.id,
|
||||
# })
|
||||
super(OperationMaintenance, cls).write(records, values)
|
||||
|
||||
def check_method(self):
|
||||
"""
|
||||
Check the methods.
|
||||
"""
|
||||
Operation = Pool().get('hotel.operation')
|
||||
Operation().check_dates(self.start_date, self.end_date, self.room,
|
||||
self.operation)
|
||||
|
||||
|
||||
class FolioCharge(Workflow, ModelSQL, ModelView):
|
||||
'Folio Charge'
|
||||
__name__ = 'hotel.folio.charge'
|
||||
|
@ -1056,6 +950,38 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
|||
res = value['base'] + value['amount']
|
||||
return res
|
||||
|
||||
def do_stock_move(self, name=None):
|
||||
pool = Pool()
|
||||
Location = pool.get('stock.location')
|
||||
Move = pool.get('stock.move')
|
||||
Config = Pool().get('hotel.configuration')
|
||||
# FIXME add origin
|
||||
|
||||
locs_customer = Location.search([
|
||||
('type', '=', 'customer')
|
||||
])
|
||||
customer_loc_id = locs_customer[0].id
|
||||
|
||||
config = Config.get_configuration()
|
||||
if not self.storage and config.storage_by_default:
|
||||
storage_id = config.storage_by_default.id
|
||||
else:
|
||||
storage_id = self.storage.id
|
||||
|
||||
move, = Move.create([{
|
||||
'product': self.product.id,
|
||||
'effective_date': self.date_service,
|
||||
'quantity': self.quantity,
|
||||
'unit_price': self.product.cost_price,
|
||||
'uom': self.product.default_uom.id,
|
||||
'from_location': storage_id,
|
||||
'to_location': customer_loc_id,
|
||||
'origin': str(self),
|
||||
}])
|
||||
self.move = move.id
|
||||
Move.do([move])
|
||||
self.save()
|
||||
|
||||
def get_taxed_amount(self, name=None):
|
||||
if self.quantity and self.unit_price:
|
||||
return self.quantity * self.unit_price
|
||||
|
|
10
operation.py
10
operation.py
|
@ -120,3 +120,13 @@ class Maintenance(Workflow, ModelSQL, ModelView):
|
|||
def get_days(self, name):
|
||||
if self.end_date and self.start_date:
|
||||
return (self.end_date - self.start_date).days
|
||||
|
||||
# FIXME
|
||||
def check_method(self):
|
||||
"""
|
||||
Check the methods.
|
||||
FIXME
|
||||
"""
|
||||
Operation = Pool().get('hotel.operation')
|
||||
Operation().check_dates(self.start_date, self.end_date, self.room,
|
||||
self.operation)
|
||||
|
|
|
@ -251,7 +251,7 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
|||
# return
|
||||
|
||||
folio = folios[0]
|
||||
new_line = {
|
||||
record = {
|
||||
'folio': self.folio.id,
|
||||
'date_service': self.service.service_date,
|
||||
'order': self.order,
|
||||
|
@ -263,9 +263,9 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
|||
'to_invoice': True,
|
||||
'state': '',
|
||||
}
|
||||
|
||||
line, = FolioCharge.create([new_line])
|
||||
self.write([self], {'charge': line.id})
|
||||
charge, = FolioCharge.create([record])
|
||||
self.write([self], {'charge': charge.id})
|
||||
charge.do_stock_move()
|
||||
|
||||
|
||||
class ServiceReport(CompanyReport):
|
||||
|
|
5
stock.py
5
stock.py
|
@ -13,8 +13,3 @@ class Move(metaclass=PoolMeta):
|
|||
models = super(Move, cls)._get_origin()
|
||||
models.append('hotel.folio.charge')
|
||||
return models
|
||||
|
||||
# def get_sale(self, name):
|
||||
# SaleLine = Pool().get('sale.line')
|
||||
# if isinstance(self.origin, SaleLine):
|
||||
# return self.origin.sale.id
|
||||
|
|
|
@ -22,8 +22,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="cleaning_check_in"/>
|
||||
<label name="cleaning_occupied"/>
|
||||
<field name="cleaning_occupied"/>
|
||||
<!-- <label name="taxes_exception_rule"/>
|
||||
<field name="taxes_exception_rule"/> -->
|
||||
<label name="storage_by_default"/>
|
||||
<field name="storage_by_default"/>
|
||||
<label name="default_channel_seller"/>
|
||||
<field name="default_channel_seller"/>
|
||||
<label name="age_children_policy"/>
|
||||
|
|
Loading…
Reference in New Issue