Skip to content

Conversation

@WoutHostensEnergyVision

No description provided.

@WoutHostensEnergyVision
Copy link
Author

@jnc-odoo

@WoutHostensEnergyVision
Copy link
Author

@jnc-odoo

Copy link

@jnc-odoo jnc-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, really good code, just comments about the good practice that you can find here:
https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html

</field>
</record>
</data>
</odoo> No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a good practice, we usually leave a blank line at the end of the file

<record id="categorie_chocolade" model="bakker_koeken_categorie">
<field name="name">Chocolade</field>
<field name="beschrijving">Koeken met chocolade</field>
<field name="active">True</field>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active True is not necessary as you set to True by default in your python definition


@api.depends('verkoop_ids.aantal', 'verkoop_ids.totaal_bedrag', 'verkoop_ids.status')
def _compute_verkoop_stats(self):
for record in self:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have used something like "for bakker in self:"
to have something more visual than record

totaal_omzet = fields.Float(string='Totaal Omzet', compute='_compute_verkoop_stats', store=True)
verkoop_count = fields.Integer(string='Aantal Verkopen', compute='_compute_verkoop_count')

@api.depends('verkoop_ids.aantal', 'verkoop_ids.totaal_bedrag', 'verkoop_ids.status')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tend to use everywhere the same quote notation. So single or double quote everywhere and not a mix

Comment on lines +38 to +56
@api.onchange('prijs_koek', 'voorraad_koek')
def _onchange_prijs_koek(self):
self._compute_totaal_inventarisatie()

@api.onchange('totaal_inventarisatie')
def _onchange_totaal_inventarisatie(self):
self._inverse_totaal_inventarisatie()

@api.depends('prijs_koek', 'voorraad_koek')
def _compute_totaal_inventarisatie(self):
for record in self:
record.totaal_inventarisatie = record.prijs_koek * record.voorraad_koek

def _inverse_totaal_inventarisatie(self):
for record in self:
if record.prijs_koek != 0:
record.voorraad_koek = record.totaal_inventarisatie / record.prijs_koek
else:
record.voorraad_koek = 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be rewritten just with a compute and an inverse or just with onchange ?
In my opinion, calling a compute in a onchange is not a good idea

raise ValidationError("Geen voorraad beschikbaar!")

# Zoek of maak een standaard walk-in klant
walk_in_klant = self.env['res.partner'].search([('name', '=', 'Walk-in klant')], limit=1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using a name for a search is never a good idea, it could change, another way would be to add a checkbox on the res.partner model and then search for the record that has this checkbox set

Suggested change
walk_in_klant = self.env['res.partner'].search([('name', '=', 'Walk-in klant')], limit=1)
walk_in_klant = self.env['res.partner'].search([('is_walk_in_client', '=', True)], limit=1)

from odoo.exceptions import ValidationError

class BakkerKoeken(models.Model):
_name = "bakker_koeken"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_name = "bakker_koeken"
_name = "bakker.koeken"

Use of . for the name of the models

klant_telefoon = fields.Char(string="Telefoon", related='partner_id.phone', readonly=True)
aantal = fields.Integer(string="Aantal", required=True, default=1, tracking=True)
prijs_per_stuk = fields.Float(string="Prijs per stuk", required=True, tracking=True)
korting_percentage = fields.Float(string="Korting (%)", default=0.0, tracking=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
korting_percentage = fields.Float(string="Korting (%)", default=0.0, tracking=True)
korting_percentage = fields.Float(string="Korting (%)", tracking=True)

If I am not mistaken in odoo, a float field has a default value of 0.0

}


class BakkerVerkoopWizard(models.TransientModel):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For wizard mode, you can add a new folder called wizards where you put all the transient models

], string="Betaal Methode", default='cash')

# Gerelateerde velden van de klant
klant_email = fields.Char(string="Email", related='partner_id.email', readonly=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
klant_email = fields.Char(string="Email", related='partner_id.email', readonly=True)
klant_email = fields.Char(string="Email", related='partner_id.email')

A related field should be readonly=True by default if I remember well

@WoutHostensEnergyVision
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants