forked from Yaltik/golem
[FIX]GOLEM Resource Account : do not allow invoice re-creation
This commit is contained in:
parent
5307ae37c0
commit
471e9f35c7
@ -40,6 +40,9 @@ class GolemResourceReservation(models.Model):
|
|||||||
def create_invoice(self):
|
def create_invoice(self):
|
||||||
""" Invoice creation """
|
""" Invoice creation """
|
||||||
for reservation in self:
|
for reservation in self:
|
||||||
|
if reservation.invoice_line_id:
|
||||||
|
raise ValidationError(_('You can not create an invoice as there '
|
||||||
|
'is already one.'))
|
||||||
inv_obj = self.env['account.invoice']
|
inv_obj = self.env['account.invoice']
|
||||||
partner_id = reservation.partner_id
|
partner_id = reservation.partner_id
|
||||||
product = reservation.resource_id.product_tmpl_id
|
product = reservation.resource_id.product_tmpl_id
|
||||||
@ -66,11 +69,11 @@ class GolemResourceReservation(models.Model):
|
|||||||
'invoice_line_ids': [(0, 0, {
|
'invoice_line_ids': [(0, 0, {
|
||||||
'name': reservation.resource_id.name,
|
'name': reservation.resource_id.name,
|
||||||
'origin': reservation.name,
|
'origin': reservation.name,
|
||||||
'account_id': account_id,
|
|
||||||
'price_unit': amount,
|
'price_unit': amount,
|
||||||
'quantity': 1.0,
|
'quantity': 1.0,
|
||||||
'discount': 0.0,
|
|
||||||
'uom_id': product.uom_id.id,
|
'uom_id': product.uom_id.id,
|
||||||
|
'account_id': account_id,
|
||||||
'product_id': product.id,
|
'product_id': product.id,
|
||||||
})]
|
})]
|
||||||
})
|
})
|
||||||
|
reservation.invoice_line_id = reservation.invoice_id.invoice_line_ids[0]
|
||||||
|
@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name='inherit_id' ref="golem_resource.golem_resource_reservation_view_tree"/>
|
<field name='inherit_id' ref="golem_resource.golem_resource_reservation_view_tree"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="state" position="after">
|
<field name="state" position="after">
|
||||||
|
<field name="invoice_id" />
|
||||||
<field name="invoice_state" string="Invoice status" />
|
<field name="invoice_state" string="Invoice status" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
@ -42,11 +43,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<button name="state_rejected" position="after">
|
<button name="state_rejected" position="after">
|
||||||
<button name="create_invoice" type="object" string="Create Invoice" class="oe_highlight"
|
<button name="create_invoice" type="object" string="Create Invoice" class="oe_highlight"
|
||||||
attrs="{'invisible': ['|', ('state', '!=', 'validated'), ('resource_product_id', '=', False)]}" />
|
attrs="{'invisible': ['|', ('state', '!=', 'validated'), '|', ('resource_product_id', '=', False), ('invoice_id', '!=', False)]}" />
|
||||||
</button>
|
</button>
|
||||||
<group name="reservation" position="after">
|
<group name="reservation" position="after">
|
||||||
<group name="invoicing" string="Invoicing"
|
<group name="invoicing" string="Invoicing"
|
||||||
attrs="{'invisible': ['|', ('state', '!=', 'validated'), ('resource_product_id', '=', False)]}">
|
|
||||||
attrs="{'invisible': [('invoice_id', '=', False)]}">
|
attrs="{'invisible': [('invoice_id', '=', False)]}">
|
||||||
<field name="resource_product_id" />
|
<field name="resource_product_id" />
|
||||||
<field name="invoice_id" />
|
<field name="invoice_id" />
|
||||||
|
Loading…
Reference in New Issue
Block a user