diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-01-23 09:20:18 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-01-23 09:20:18 +0000 |
| commit | da5f5134f56b2ccf1c1de16c3f7616ab3719f3ea (patch) | |
| tree | bc1bcb4fb00f2659be81810d528a9cf2cc6ce20d /indoteknik_custom/models/sales_target.py | |
| parent | e52cf84fd2284330412162b44066f29bd382f590 (diff) | |
| parent | 8af5ee591aabc2d5d946c0eece93a5caab989975 (diff) | |
Merged in release (pull request #27)
Release
Diffstat (limited to 'indoteknik_custom/models/sales_target.py')
| -rw-r--r-- | indoteknik_custom/models/sales_target.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/indoteknik_custom/models/sales_target.py b/indoteknik_custom/models/sales_target.py index ac6405e5..c31a4470 100644 --- a/indoteknik_custom/models/sales_target.py +++ b/indoteknik_custom/models/sales_target.py @@ -16,6 +16,26 @@ class SalesTarget(models.Model): ongoing_omset_adempiere = fields.Float(string='Omset Berjalan ADempiere') ongoing_omset_total = fields.Float(string='Total Omset', compute='_compute_total_omset') target = fields.Float(string='Target') + ach_per_year = fields.Float(string='Ach/Year%', compute='_compute_achievement') + ach_per_month = fields.Float(string='Ach/Month%', compute='_compute_achievement') + sales_id = fields.Many2one('res.users', string='Salesperson', compute='_compute_partner') + reference = fields.Char(string='Reference', compute='_compute_partner') + + def _compute_partner(self): + for sales_target in self: + sales_target.sales_id = sales_target.partner_id.user_id + sales_target.reference = sales_target.partner_id.reference_number + + def _compute_achievement(self): + for sales_target in self: + if not sales_target.target or sales_target.target <= 0: + sales_target.ach_per_year = 0 + sales_target.ach_per_month = 0 + return + current_time = datetime.now() + current_month = current_time.month + sales_target.ach_per_year = sales_target.ongoing_omset_total/sales_target.target*100 + sales_target.ach_per_month = sales_target.ongoing_omset_total/((sales_target.target/12)*current_month) def _compute_total_omset(self): for target in self: |
