Pack de réservations #17
@ -32,21 +32,38 @@ class GolemResourcePack(models.Model):
|
|||||||
copy=False)
|
copy=False)
|
||||||
invoice_amount_total = fields.Monetary(related='invoice_id.amount_total')
|
invoice_amount_total = fields.Monetary(related='invoice_id.amount_total')
|
||||||
currency_id = fields.Many2one(related='invoice_id.currency_id')
|
currency_id = fields.Many2one(related='invoice_id.currency_id')
|
||||||
is_products_set = fields.Boolean(compute="compute_is_products_set")
|
is_products_set = fields.Boolean(compute="_compute_is_products_set")
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def compute_is_products_set(self):
|
def _compute_is_products_set(self):
|
||||||
|
""" compute is_products_set """
|
||||||
for pack in self:
|
for pack in self:
|
||||||
product_list = list(map(lambda x: x.resource_product_id, pack.reservation_ids))
|
if len(filter(lambda x: x.resource_product_id.id is False, pack.reservation_ids)) \
|
||||||
if len(filter(lambda x: x.id == False, product_list)) > 0:
|
> 0:
|
||||||
pack.is_products_set = False
|
pack.is_products_set = False
|
||||||
else:
|
else:
|
||||||
pack.is_products_set = True
|
pack.is_products_set = True
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def chek_pack_to_invoice(self):
|
||||||
|
""" chek pack before invoicing """
|
||||||
|
for pack in self:
|
||||||
|
if pack.state != 'validated':
|
||||||
|
raise ValidationError(_('The current pack is not validated, please validate '
|
||||||
|
'it before creating invoice'))
|
||||||
|
elif not pack.is_products_set:
|
||||||
|
raise ValidationError(_('You can not create an invoice for a pack without '
|
||||||
|
'linked product on every resource reserved.'))
|
||||||
|
elif pack.invoice_id.id:
|
||||||
|
raise ValidationError(_('You can not create an invoice as there '
|
||||||
|
'is already one.'))
|
||||||
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def create_invoice(self):
|
def create_invoice(self):
|
||||||
""" Invoice creation """
|
""" Invoice creation """
|
||||||
for pack in self:
|
for pack in self:
|
||||||
|
pack.chek_pack_to_invoice()
|
||||||
pack.reservation_ids.check_before_invoicing()
|
pack.reservation_ids.check_before_invoicing()
|
||||||
inv_obj = self.env['account.invoice']
|
inv_obj = self.env['account.invoice']
|
||||||
partner_id = pack.partner_id
|
partner_id = pack.partner_id
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
|
||||||
access_golem_resource_pack_user,Access GOLEM Resource Pack User,model_golem_resource_pack,golem_base.group_golem_user,1,0,0,0
|
|
||||||
access_golem_resource_pack_manager,Access GOLEM Resource Pack Manager,model_golem_resource_pack,golem_base.group_golem_manager,1,1,1,1
|
|
500 Internal Server Error
Gitea Version: 1.23.1 |